Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Commit

Permalink
Add feature gate for the block templates controller refactor (#11178)
Browse files Browse the repository at this point in the history
* add feature gating for the block templates controller refactor

* improve check
  • Loading branch information
gigitux authored Oct 10, 2023
1 parent ffaf21f commit 7abd3b7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/BlockTemplatesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,11 @@ class BlockTemplatesController {
public function __construct( Package $package ) {
$this->package = $package;

$feature_gating = $package->feature();
$is_block_templates_controller_refactor_enabled = $feature_gating->is_block_templates_controller_refactor_enabled();

// This feature is gated for WooCommerce versions 6.0.0 and above.
if ( defined( 'WC_VERSION' ) && version_compare( WC_VERSION, '6.0.0', '>=' ) ) {
if ( defined( 'WC_VERSION' ) && version_compare( WC_VERSION, '6.0.0', '>=' ) && ! $is_block_templates_controller_refactor_enabled ) {
$this->init();
}
}
Expand Down
11 changes: 11 additions & 0 deletions src/Domain/Services/FeatureGating.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,4 +164,15 @@ public static function get_experimental_flag() {
return self::EXPERIMENTAL_FLAG;
}


/**
* Check if the block templates controller refactor should be used to display blocks.
*
* @return boolean
*/
public function is_block_templates_controller_refactor_enabled() {
$conf = parse_ini_file( __DIR__ . '/../../../blocks.ini' );
return $this->is_development_environment() && isset( $conf['use_block_templates_controller_refactor'] ) && true === (bool) $conf['use_block_templates_controller_refactor'];
}

}

0 comments on commit 7abd3b7

Please sign in to comment.