Automattic\WooCommerce\Internal\Admin\BlockTemplates

AbstractBlock::__constructpublicWC 1.0

Block constructor.

Method of the class: AbstractBlock{}

No Hooks.

Returns

null. Nothing (null).

Usage

$AbstractBlock = new AbstractBlock();
$AbstractBlock->__construct( $config, $root_template, ?ContainerInterface $parent );
$config(array) (required)
The block configuration.
$root_template(BlockTemplateInterface) (required)
The block template that this block belongs to.
?ContainerInterface $parent(passed by reference — &)
.
Default: null

AbstractBlock::__construct() code WC 10.8.1

public function __construct( array $config, BlockTemplateInterface &$root_template, ?ContainerInterface &$parent = null ) { // phpcs:ignore Universal.NamingConventions.NoReservedKeywordParameterNames.parentFound
	$this->validate( $config, $root_template, $parent );

	$this->root_template = $root_template;
	$this->parent        = is_null( $parent ) ? $root_template : $parent;

	$this->name = $config[ self::NAME_KEY ];

	if ( ! isset( $config[ self::ID_KEY ] ) ) {
		$this->id = $this->root_template->generate_block_id( $this->get_name() );
	} else {
		$this->id = $config[ self::ID_KEY ];
	}

	if ( isset( $config[ self::ORDER_KEY ] ) ) {
		$this->order = $config[ self::ORDER_KEY ];
	}

	if ( isset( $config[ self::ATTRIBUTES_KEY ] ) ) {
		$this->attributes = $config[ self::ATTRIBUTES_KEY ];
	}

	if ( isset( $config[ self::HIDE_CONDITIONS_KEY ] ) ) {
		foreach ( $config[ self::HIDE_CONDITIONS_KEY ] as $hide_condition ) {
			$this->add_hide_condition( $hide_condition['expression'] );
		}
	}

	if ( isset( $config[ self::DISABLE_CONDITIONS_KEY ] ) ) {
		foreach ( $config[ self::DISABLE_CONDITIONS_KEY ] as $disable_condition ) {
			$this->add_disable_condition( $disable_condition['expression'] );
		}
	}
}