Init BlockTemplatesRegistry and BlockTemplatesController from Bootstrap.php
This commit is contained in:
parent
845e75119f
commit
713c43afdb
|
@ -18,17 +18,10 @@ class BlockTemplatesController {
|
|||
*/
|
||||
const TEMPLATES_ROOT_DIR = 'templates';
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->init();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialization method.
|
||||
*/
|
||||
protected function init() {
|
||||
public function init() {
|
||||
add_filter( 'pre_get_block_template', array( $this, 'get_block_template_fallback' ), 10, 3 );
|
||||
add_filter( 'pre_get_block_file_template', array( $this, 'get_block_file_template' ), 10, 3 );
|
||||
add_filter( 'get_block_template', array( $this, 'add_block_template_details' ), 10, 3 );
|
||||
|
|
|
@ -30,13 +30,6 @@ class BlockTemplatesRegistry {
|
|||
*/
|
||||
private $templates = array();
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->init();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialization method.
|
||||
*/
|
||||
|
|
|
@ -146,8 +146,8 @@ class Bootstrap {
|
|||
// regular rest requests to maintain compatibility with the store editor.
|
||||
$this->container->get( BlockPatterns::class );
|
||||
$this->container->get( BlockTypesController::class );
|
||||
$this->container->get( BlockTemplatesRegistry::class );
|
||||
$this->container->get( BlockTemplatesController::class );
|
||||
$this->container->get( BlockTemplatesRegistry::class )->init();
|
||||
$this->container->get( BlockTemplatesController::class )->init();
|
||||
$this->container->get( ClassicTemplatesCompatibility::class );
|
||||
$this->container->get( ArchiveProductTemplatesCompatibility::class )->init();
|
||||
$this->container->get( SingleProductTemplateCompatibility::class )->init();
|
||||
|
|
|
@ -29,9 +29,8 @@ class BlockTemplateUtilsTest extends WP_UnitTestCase {
|
|||
|
||||
// Switch to a block theme and initialize template logic.
|
||||
switch_theme( 'twentytwentytwo' );
|
||||
$this->container = Package::container();
|
||||
$block_templates_registry = $this->container->get( BlockTemplatesRegistry::class );
|
||||
$block_templates_registry->init();
|
||||
$this->container = Package::container();
|
||||
$this->container->get( BlockTemplatesRegistry::class )->init();
|
||||
|
||||
// Reset options.
|
||||
delete_option( Options::WC_BLOCK_USE_BLOCKIFIED_PRODUCT_GRID_BLOCK_AS_TEMPLATE );
|
||||
|
|
Loading…
Reference in New Issue