Automattic\WooCommerce\Blocks\BlockTypes\ProductCollection

HandlerRegistry::register_collection_handlerspublicWC 1.0

Register handlers for a collection.

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

Хуков нет.

Возвращает

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

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

$HandlerRegistry = new HandlerRegistry();
$HandlerRegistry->register_collection_handlers( $collection_name, $build_query, $frontend_args, $editor_args, $preview_query );
$collection_name(строка) (обязательный)
The name of the collection.
$build_query(callable) (обязательный)
The query builder callable.
$frontend_args(callable|null)
Optional frontend args callable.
По умолчанию: null
$editor_args(callable|null)
Optional editor args callable.
По умолчанию: null
$preview_query(callable|null)
Optional preview query callable.
По умолчанию: null

Код HandlerRegistry::register_collection_handlers() WC 9.9.4

public function register_collection_handlers( $collection_name, $build_query, $frontend_args = null, $editor_args = null, $preview_query = null ) {
	if ( isset( $this->collection_handler_store[ $collection_name ] ) ) {
		throw new InvalidArgumentException( 'Collection handlers already registered for ' . esc_html( $collection_name ) );
	}

	$this->collection_handler_store[ $collection_name ] = [
		'build_query'   => $build_query,
		'frontend_args' => $frontend_args,
		'editor_args'   => $editor_args,
		'preview_query' => $preview_query,
	];

	return $this->collection_handler_store[ $collection_name ];
}