Add feature gate for the block templates controller refactor (https://github.com/woocommerce/woocommerce-blocks/pull/11178)

* add feature gating for the block templates controller refactor

* improve check
This commit is contained in:
Luigi Teschio 2023-10-10 16:50:18 +02:00 committed by GitHub
parent a6ddae9dc3
commit 645bd8d339
2 changed files with 15 additions and 1 deletions

View File

@ -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();
}
}

View File

@ -164,4 +164,15 @@ class FeatureGating {
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'];
}
}