Automattic\WooCommerce\Internal\Admin\BlockTemplates

AbstractBlockTemplate::cache_block()publicWC 1.0

Caches a block in the template. This is an internal method and should not be called directly except for from the BlockContainerTrait's add_inner_block() method.

Метод класса: AbstractBlockTemplate{}

Хуков нет.

Возвращает

null. Ничего (null).

Использование

$AbstractBlockTemplate = new AbstractBlockTemplate();
$AbstractBlockTemplate->cache_block( $block );
$block(BlockInterface) (обязательный)
The block to cache.

Код AbstractBlockTemplate::cache_block() WC 9.3.3

public function cache_block( BlockInterface &$block ) {
	$id = $block->get_id();

	if ( isset( $this->block_cache[ $id ] ) ) {
		throw new \ValueError( 'A block with the specified ID already exists in the template.' );
	}

	if ( $block->get_root_template() !== $this ) {
		throw new \ValueError( 'The block template that the block belongs to must be the same as this template.' );
	}

	$this->block_cache[ $id ] = $block;
}