Automattic\WooCommerce\Blocks\BlockTypes\ProductCollection
Controller::initialize
Initialize this block type.
- Register hooks and filters.
- Set up QueryBuilder, Renderer and HandlerRegistry.
Метод класса: Controller{}
Хуков нет.
Возвращает
null. Ничего (null).
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->initialize();
Код Controller::initialize() Controller::initialize WC 10.7.0
protected function initialize() {
parent::initialize();
$this->query_builder = new QueryBuilder();
$this->renderer = new Renderer();
$this->collection_handler_registry = new HandlerRegistry();
// Update query for frontend rendering.
add_filter(
'query_loop_block_query_vars',
array( $this, 'build_frontend_query' ),
10,
3
);
add_filter(
'pre_render_block',
array( $this, 'add_support_for_filter_blocks' ),
10,
2
);
// Register the backend settings so they can be used in the editor.
add_action( 'rest_api_init', array( $this, 'register_settings' ) );
// Update the query for Editor.
add_filter( 'rest_product_query', array( $this, 'update_rest_query_in_editor' ), 10, 2 );
// Extend allowed `collection_params` for the REST API.
add_filter( 'rest_product_collection_params', array( $this, 'extend_rest_query_allowed_params' ), 10, 1 );
add_filter( 'render_block_core/post-title', array( $this, 'add_product_title_click_event_directives' ), 10, 3 );
// Disable client-side-navigation if incompatible blocks are detected.
add_filter( 'render_block_data', array( $this, 'disable_enhanced_pagination' ), 10, 1 );
$this->register_core_collections_and_set_handler_store();
}