From 0ee090d16de309e382a55d681c479050c70e00d7 Mon Sep 17 00:00:00 2001 From: Darren Ethier Date: Mon, 11 Nov 2019 13:09:09 -0500 Subject: [PATCH] Remove unnecessary package version reading of @wordpress/components (https://github.com/woocommerce/woocommerce-blocks/pull/1154) * remove unnecessary package version reading of @wordpress/components * comment out unused variable --- .../src/Domain/Bootstrap.php | 31 +++++++------------ 1 file changed, 11 insertions(+), 20 deletions(-) diff --git a/plugins/woocommerce-blocks/src/Domain/Bootstrap.php b/plugins/woocommerce-blocks/src/Domain/Bootstrap.php index 4c75e285c65..9f578b71be1 100644 --- a/plugins/woocommerce-blocks/src/Domain/Bootstrap.php +++ b/plugins/woocommerce-blocks/src/Domain/Bootstrap.php @@ -75,26 +75,17 @@ class Bootstrap { $this->container->register( AssetDataRegistry::class, function( Container $container ) { - $asset_api = $container->get( AssetApi::class ); - $js_package = \json_decode( - // phpcs:disable WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents - \file_get_contents( - $this->package->get_path( 'package.json' ) - ), - true - ); - $woocommerce_components_version = - isset( $js_package['dependencies']['@woocommerce/components'] ) - ? $js_package['dependencies']['@woocommerce/components'] - : 0; - $load_back_compat = '3.2.0' === $woocommerce_components_version - || ( - defined( 'WC_ADMIN_VERSION_NUMBER' ) - && version_compare( WC_ADMIN_VERSION_NUMBER, '0.19.0', '<=' ) - ); - return $load_back_compat - ? new BackCompatAssetDataRegistry( $asset_api ) - : new AssetDataRegistry( $asset_api ); + $asset_api = $container->get( AssetApi::class ); + // phpcs:disable Squiz . PHP . CommentedOutCode . Found + // @todo: this needs added back in once the @woocommerce/components + // package has been updated. + // $load_back_compat = defined( 'WC_ADMIN_VERSION_NUMBER' ) + // && version_compare( WC_ADMIN_VERSION_NUMBER, '0.19.0', '<=' ); + // return $load_back_compat + // ? new BackCompatAssetDataRegistry( $asset_api ) + // : new AssetDataRegistry( $asset_api ); + // phpcs:enable + return new BackCompatAssetDataRegistry( $asset_api ); } );