Automattic\WooCommerce\LayoutTemplates

LayoutTemplateRegistry::register()publicWC 1.0

Register a single layout template.

Method of the class: LayoutTemplateRegistry{}

No Hooks.

Return

null. Nothing (null).

Usage

$LayoutTemplateRegistry = new LayoutTemplateRegistry();
$LayoutTemplateRegistry->register( $layout_template_id, $layout_template_area, $layout_template_class_name );
$layout_template_id(string) (required)
Layout template ID.
$layout_template_area(string) (required)
Layout template area.
$layout_template_class_name(string) (required)
Layout template class to register.

LayoutTemplateRegistry::register() code WC 9.3.3

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,
	);
}