Automattic\WooCommerce\LayoutTemplates

LayoutTemplateRegistry::register()publicWC 1.0

Register a single layout template.

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

Хуков нет.

Возвращает

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

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

$LayoutTemplateRegistry = new LayoutTemplateRegistry();
$LayoutTemplateRegistry->register( $layout_template_id, $layout_template_area, $layout_template_class_name );
$layout_template_id(строка) (обязательный)
Layout template ID.
$layout_template_area(строка) (обязательный)
Layout template area.
$layout_template_class_name(строка) (обязательный)
Layout template class to register.

Код LayoutTemplateRegistry::register() WC 9.4.2

public function register( $layout_template_id, $layout_template_area, $layout_template_class_name ) {
	if ( $this->is_registered( $layout_template_id ) ) {
		throw new \ValueError( 'A layout template with the specified ID already exists in the registry.' );
	}

	if ( empty( $layout_template_area ) ) {
		throw new \ValueError( 'The specified layout template area is empty.' );
	}

	if ( ! class_exists( $layout_template_class_name ) ) {
		throw new \ValueError( 'The specified layout template class does not exist.' );
	}

	if ( ! is_subclass_of( $layout_template_class_name, BlockTemplateInterface::class ) ) {
		throw new \ValueError( 'The specified layout template class does not implement the BlockTemplateInterface.' );
	}

	$this->layout_templates_info[ $layout_template_id ] = array(
		'id'         => $layout_template_id,
		'area'       => $layout_template_area,
		'class_name' => $layout_template_class_name,
	);
}