From 797556ac477b63bbc0369df9cfd0b525881a7341 Mon Sep 17 00:00:00 2001 From: Joan He Date: Tue, 13 Oct 2015 13:08:19 -0500 Subject: [PATCH 01/26] MAGETWO-43857: [github] cache types don't properly invalidate all the time #1844 --- .../Backup/Model/Config/Backend/Cron.php | 7 +- .../Config/Backend/Countrycreditcard.php | 4 +- .../Catalog/Model/Config/Backend/Category.php | 6 +- .../Model/Config/CatalogClone/Media/Image.php | 4 +- .../Category/Flat/System/Config/Mode.php | 6 +- .../Product/Flat/System/Config/Mode.php | 6 +- .../Price/System/Config/PriceScope.php | 8 ++- .../Backend/Catalog/Url/Rewrite/Suffix.php | 8 ++- .../Model/Config/Backend/AbstractValue.php | 4 +- .../Model/Config/Backend/Backorders.php | 2 +- .../Model/Config/Backend/Managestock.php | 2 +- .../System/Config/Backend/Minsaleqty.php | 4 +- .../System/Config/Backend/Engine.php | 4 +- .../Model/Config/Backend/Admin/Custom.php | 6 +- .../Model/Config/Backend/Admin/Robots.php | 4 +- .../Model/Config/Backend/Admin/Usecustom.php | 6 +- .../Config/Backend/Admin/Usesecretkey.php | 6 +- .../Config/Model/Config/Backend/Baseurl.php | 7 +- .../Backend/Currency/AbstractCurrency.php | 33 +-------- .../Model/Config/Backend/Currency/Allow.php | 8 +-- .../Model/Config/Backend/Currency/Base.php | 8 +-- .../Model/Config/Backend/Currency/Cron.php | 7 +- .../Backend/Currency/DefaultCurrency.php | 2 +- .../Config/Model/Config/Backend/Encrypted.php | 4 +- .../Config/Model/Config/Backend/File.php | 5 +- .../Model/Config/Backend/Image/Adapter.php | 4 +- .../Config/Model/Config/Backend/Locale.php | 6 +- .../Config/Model/Config/Backend/Log/Cron.php | 7 +- .../Config/Model/Config/Backend/Secure.php | 7 +- .../Model/Config/Backend/Serialized.php | 3 +- .../Backend/Serialized/ArraySerialized.php | 4 +- .../Config/Model/Config/Backend/Store.php | 7 +- .../Config/Model/Config/Backend/Translate.php | 67 ++----------------- .../Unit/Model/Config/Backend/BaseurlTest.php | 30 +++------ .../Unit/Model/Config/Backend/SecureTest.php | 30 +++------ .../Model/System/Config/Backend/LinksTest.php | 10 +-- .../Cookie/Model/Config/Backend/Domain.php | 4 +- .../Cookie/Model/Config/Backend/Lifetime.php | 7 +- .../Cookie/Model/Config/Backend/Path.php | 4 +- .../Model/Config/Backend/Product/Alert.php | 10 ++- .../Cron/Model/Config/Backend/Sitemap.php | 7 +- .../Model/Config/Backend/Address/Street.php | 6 +- .../DisableAutoGroupAssignDefault.php | 4 +- .../Model/Config/Backend/Show/Customer.php | 4 +- .../Magento/Customer/Model/Config/Share.php | 4 +- .../Model/Config/Backend/AllowedIps.php | 4 +- .../Config/Backend/AbstractConversion.php | 4 +- .../Config/Backend/Storage/Media/Database.php | 6 +- .../Model/Config/Backend/Tablerate.php | 7 +- .../Model/System/Config/Backend/Cert.php | 6 +- .../Model/System/Config/Backend/Cron.php | 4 +- .../System/Config/Backend/MerchantCountry.php | 4 +- .../Rss/Model/System/Config/Backend/Links.php | 32 +-------- .../Magento/Tax/Model/Config/Notification.php | 8 ++- .../Magento/Tax/Model/Config/TaxClass.php | 10 +-- .../Theme/Model/Design/Backend/Exceptions.php | 4 +- .../Theme/Model/Design/Backend/Theme.php | 37 +++++++++- .../Model/Design/Backend/ExceptionsTest.php | 56 ++++------------ .../Unit/Model/Design/Backend/ThemeTest.php | 56 ++++------------ app/code/Magento/Theme/etc/config.xml | 5 ++ .../Magento/Framework/App/Config/Value.php | 24 +++++++ 61 files changed, 312 insertions(+), 341 deletions(-) diff --git a/app/code/Magento/Backup/Model/Config/Backend/Cron.php b/app/code/Magento/Backup/Model/Config/Backend/Cron.php index e4204f26879db..ed8ae69bbf0fb 100644 --- a/app/code/Magento/Backup/Model/Config/Backend/Cron.php +++ b/app/code/Magento/Backup/Model/Config/Backend/Cron.php @@ -32,6 +32,7 @@ class Cron extends \Magento\Framework\App\Config\Value * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry * @param \Magento\Framework\App\Config\ScopeConfigInterface $config + * @param \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList * @param \Magento\Framework\App\Config\ValueFactory $configValueFactory * @param \Magento\Framework\Model\ModelResource\AbstractResource $resource * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection @@ -42,6 +43,7 @@ public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\App\Config\ScopeConfigInterface $config, + \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList, \Magento\Framework\App\Config\ValueFactory $configValueFactory, \Magento\Framework\Model\ModelResource\AbstractResource $resource = null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, @@ -50,13 +52,13 @@ public function __construct( ) { $this->_runModelPath = $runModelPath; $this->_configValueFactory = $configValueFactory; - parent::__construct($context, $registry, $config, $resource, $resourceCollection, $data); + parent::__construct($context, $registry, $config, $cacheTypeList, $resource, $resourceCollection, $data); } /** * Cron settings after save * - * @return void + * @return $this * @throws \Magento\Framework\Exception\LocalizedException */ public function afterSave() @@ -102,5 +104,6 @@ public function afterSave() } catch (\Exception $e) { throw new \Magento\Framework\Exception\LocalizedException(__('We can\'t save the Cron expression.')); } + return parent::afterSave(); } } diff --git a/app/code/Magento/Braintree/Model/System/Config/Backend/Countrycreditcard.php b/app/code/Magento/Braintree/Model/System/Config/Backend/Countrycreditcard.php index 17291f11bc9d5..f88ad1f405d23 100644 --- a/app/code/Magento/Braintree/Model/System/Config/Backend/Countrycreditcard.php +++ b/app/code/Magento/Braintree/Model/System/Config/Backend/Countrycreditcard.php @@ -16,6 +16,7 @@ class Countrycreditcard extends \Magento\Framework\App\Config\Value * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry * @param \Magento\Framework\App\Config\ScopeConfigInterface $config + * @param \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList * @param \Magento\Framework\Math\Random $mathRandom * @param \Magento\Framework\Model\ModelResource\AbstractResource $resource * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection @@ -25,13 +26,14 @@ public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\App\Config\ScopeConfigInterface $config, + \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList, \Magento\Framework\Math\Random $mathRandom, \Magento\Framework\Model\ModelResource\AbstractResource $resource = null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, array $data = [] ) { $this->mathRandom = $mathRandom; - parent::__construct($context, $registry, $config, $resource, $resourceCollection, $data); + parent::__construct($context, $registry, $config, $cacheTypeList, $resource, $resourceCollection, $data); } /** diff --git a/app/code/Magento/Catalog/Model/Config/Backend/Category.php b/app/code/Magento/Catalog/Model/Config/Backend/Category.php index 31baf9603a098..70e2937bc4edf 100644 --- a/app/code/Magento/Catalog/Model/Config/Backend/Category.php +++ b/app/code/Magento/Catalog/Model/Config/Backend/Category.php @@ -25,6 +25,7 @@ class Category extends \Magento\Framework\App\Config\Value * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry * @param \Magento\Framework\App\Config\ScopeConfigInterface $config + * @param \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList * @param \Magento\Catalog\Model\Category $catalogCategory * @param \Magento\Framework\Model\ModelResource\AbstractResource $resource * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection @@ -34,13 +35,14 @@ public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\App\Config\ScopeConfigInterface $config, + \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList, \Magento\Catalog\Model\Category $catalogCategory, \Magento\Framework\Model\ModelResource\AbstractResource $resource = null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, array $data = [] ) { $this->_catalogCategory = $catalogCategory; - parent::__construct($context, $registry, $config, $resource, $resourceCollection, $data); + parent::__construct($context, $registry, $config, $cacheTypeList, $resource, $resourceCollection, $data); } /** @@ -67,6 +69,6 @@ public function afterSave() $this->_catalogCategory->setStoreId($storeId)->save(); } } - return $this; + return parent::afterSave(); } } diff --git a/app/code/Magento/Catalog/Model/Config/CatalogClone/Media/Image.php b/app/code/Magento/Catalog/Model/Config/CatalogClone/Media/Image.php index 2fd92365d14e1..3df22c0bfa51d 100644 --- a/app/code/Magento/Catalog/Model/Config/CatalogClone/Media/Image.php +++ b/app/code/Magento/Catalog/Model/Config/CatalogClone/Media/Image.php @@ -30,6 +30,7 @@ class Image extends \Magento\Framework\App\Config\Value * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry * @param \Magento\Framework\App\Config\ScopeConfigInterface $config + * @param \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList * @param \Magento\Catalog\Model\ResourceModel\Product\Attribute\CollectionFactory $attributeCollectionFactory * @param \Magento\Eav\Model\Config $eavConfig * @param \Magento\Framework\Model\ModelResource\AbstractResource $resource @@ -40,6 +41,7 @@ public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\App\Config\ScopeConfigInterface $config, + \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList, \Magento\Catalog\Model\ResourceModel\Product\Attribute\CollectionFactory $attributeCollectionFactory, \Magento\Eav\Model\Config $eavConfig, \Magento\Framework\Model\ModelResource\AbstractResource $resource = null, @@ -48,7 +50,7 @@ public function __construct( ) { $this->_attributeCollectionFactory = $attributeCollectionFactory; $this->_eavConfig = $eavConfig; - parent::__construct($context, $registry, $config, $resource, $resourceCollection, $data); + parent::__construct($context, $registry, $config, $cacheTypeList, $resource, $resourceCollection, $data); } /** diff --git a/app/code/Magento/Catalog/Model/Indexer/Category/Flat/System/Config/Mode.php b/app/code/Magento/Catalog/Model/Indexer/Category/Flat/System/Config/Mode.php index 3d6eb24ce7d14..d3d499d7d8f76 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Category/Flat/System/Config/Mode.php +++ b/app/code/Magento/Catalog/Model/Indexer/Category/Flat/System/Config/Mode.php @@ -20,6 +20,7 @@ class Mode extends \Magento\Framework\App\Config\Value * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry * @param \Magento\Framework\App\Config\ScopeConfigInterface $config + * @param \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList * @param \Magento\Framework\Indexer\IndexerRegistry $indexerRegistry * @param \Magento\Indexer\Model\Indexer\State $indexerState * @param \Magento\Framework\Model\ModelResource\AbstractResource $resource @@ -30,13 +31,14 @@ public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\App\Config\ScopeConfigInterface $config, + \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList, \Magento\Framework\Indexer\IndexerRegistry $indexerRegistry, \Magento\Indexer\Model\Indexer\State $indexerState, \Magento\Framework\Model\ModelResource\AbstractResource $resource = null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, array $data = [] ) { - parent::__construct($context, $registry, $config, $resource, $resourceCollection, $data); + parent::__construct($context, $registry, $config, $cacheTypeList, $resource, $resourceCollection, $data); $this->indexerRegistry = $indexerRegistry; $this->indexerState = $indexerState; } @@ -49,7 +51,7 @@ public function __construct( public function afterSave() { $this->_getResource()->addCommitCallback([$this, 'processValue']); - return $this; + return parent::afterSave(); } /** diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Flat/System/Config/Mode.php b/app/code/Magento/Catalog/Model/Indexer/Product/Flat/System/Config/Mode.php index e35b88dc0e72e..977ed6ed73f62 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Flat/System/Config/Mode.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Flat/System/Config/Mode.php @@ -24,6 +24,7 @@ class Mode extends \Magento\Framework\App\Config\Value * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry * @param \Magento\Framework\App\Config\ScopeConfigInterface $config + * @param \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList * @param \Magento\Catalog\Model\Indexer\Product\Flat\Processor $productFlatIndexerProcessor * @param \Magento\Indexer\Model\Indexer\State $indexerState * @param \Magento\Framework\Model\ModelResource\AbstractResource $resource @@ -34,6 +35,7 @@ public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\App\Config\ScopeConfigInterface $config, + \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList, \Magento\Catalog\Model\Indexer\Product\Flat\Processor $productFlatIndexerProcessor, \Magento\Indexer\Model\Indexer\State $indexerState, \Magento\Framework\Model\ModelResource\AbstractResource $resource = null, @@ -42,7 +44,7 @@ public function __construct( ) { $this->_productFlatIndexerProcessor = $productFlatIndexerProcessor; $this->indexerState = $indexerState; - parent::__construct($context, $registry, $config, $resource, $resourceCollection, $data); + parent::__construct($context, $registry, $config, $cacheTypeList, $resource, $resourceCollection, $data); } /** @@ -53,7 +55,7 @@ public function __construct( public function afterSave() { $this->_getResource()->addCommitCallback([$this, 'processValue']); - return $this; + return parent::afterSave(); } /** diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Price/System/Config/PriceScope.php b/app/code/Magento/Catalog/Model/Indexer/Product/Price/System/Config/PriceScope.php index f66ac598d465b..c19ee05a3583d 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Price/System/Config/PriceScope.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Price/System/Config/PriceScope.php @@ -17,6 +17,7 @@ class PriceScope extends \Magento\Framework\App\Config\Value * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry * @param \Magento\Framework\App\Config\ScopeConfigInterface $config + * @param \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList * @param \Magento\Framework\Indexer\IndexerRegistry $indexerRegistry * @param \Magento\Framework\Model\ModelResource\AbstractResource $resource * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection @@ -26,24 +27,25 @@ public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\App\Config\ScopeConfigInterface $config, + \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList, \Magento\Framework\Indexer\IndexerRegistry $indexerRegistry, \Magento\Framework\Model\ModelResource\AbstractResource $resource = null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, array $data = [] ) { - parent::__construct($context, $registry, $config, $resource, $resourceCollection, $data); + parent::__construct($context, $registry, $config, $cacheTypeList, $resource, $resourceCollection, $data); $this->indexerRegistry = $indexerRegistry; } /** * Set after commit callback * - * @return \Magento\Catalog\Model\Indexer\Product\Price\System\Config\PriceScope + * @return $this */ public function afterSave() { $this->_getResource()->addCommitCallback([$this, 'processValue']); - return $this; + return parent::afterSave(); } /** diff --git a/app/code/Magento/Catalog/Model/System/Config/Backend/Catalog/Url/Rewrite/Suffix.php b/app/code/Magento/Catalog/Model/System/Config/Backend/Catalog/Url/Rewrite/Suffix.php index 42ddbde393fd8..b4ea3dd8c5b98 100644 --- a/app/code/Magento/Catalog/Model/System/Config/Backend/Catalog/Url/Rewrite/Suffix.php +++ b/app/code/Magento/Catalog/Model/System/Config/Backend/Catalog/Url/Rewrite/Suffix.php @@ -39,12 +39,13 @@ class Suffix extends \Magento\Framework\App\Config\Value * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry * @param \Magento\Framework\App\Config\ScopeConfigInterface $config - * @param \Magento\Framework\Model\ModelResource\AbstractResource $resource - * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection + * @param \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList * @param \Magento\UrlRewrite\Helper\UrlRewrite $urlRewriteHelper * @param \Magento\Store\Model\StoreManagerInterface $storeManager * @param \Magento\Framework\App\ResourceConnection $appResource * @param \Magento\UrlRewrite\Model\UrlFinderInterface $urlFinder + * @param \Magento\Framework\Model\ModelResource\AbstractResource $resource + * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection * @param array $data * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ @@ -52,6 +53,7 @@ public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\App\Config\ScopeConfigInterface $config, + \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList, \Magento\UrlRewrite\Helper\UrlRewrite $urlRewriteHelper, \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Framework\App\ResourceConnection $appResource, @@ -60,7 +62,7 @@ public function __construct( \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, array $data = [] ) { - parent::__construct($context, $registry, $config, $resource, $resourceCollection, $data); + parent::__construct($context, $registry, $config, $cacheTypeList, $resource, $resourceCollection, $data); $this->urlRewriteHelper = $urlRewriteHelper; $this->connection = $appResource->getConnection(); $this->urlFinder = $urlFinder; diff --git a/app/code/Magento/CatalogInventory/Model/Config/Backend/AbstractValue.php b/app/code/Magento/CatalogInventory/Model/Config/Backend/AbstractValue.php index 58c52b8937769..ffe4998c15a02 100644 --- a/app/code/Magento/CatalogInventory/Model/Config/Backend/AbstractValue.php +++ b/app/code/Magento/CatalogInventory/Model/Config/Backend/AbstractValue.php @@ -25,6 +25,7 @@ abstract class AbstractValue extends \Magento\Framework\App\Config\Value * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry * @param \Magento\Framework\App\Config\ScopeConfigInterface $config + * @param \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList * @param \Magento\CatalogInventory\Api\StockIndexInterface $stockIndex * @param \Magento\CatalogInventory\Model\Indexer\Stock\Processor $stockIndexerProcessor * @param \Magento\Framework\Model\ModelResource\AbstractResource $resource @@ -35,6 +36,7 @@ public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\App\Config\ScopeConfigInterface $config, + \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList, \Magento\CatalogInventory\Api\StockIndexInterface $stockIndex, \Magento\CatalogInventory\Model\Indexer\Stock\Processor $stockIndexerProcessor, \Magento\Framework\Model\ModelResource\AbstractResource $resource = null, @@ -43,6 +45,6 @@ public function __construct( ) { $this->_stockIndexerProcessor = $stockIndexerProcessor; $this->stockIndex = $stockIndex; - parent::__construct($context, $registry, $config, $resource, $resourceCollection, $data); + parent::__construct($context, $registry, $config, $cacheTypeList, $resource, $resourceCollection, $data); } } diff --git a/app/code/Magento/CatalogInventory/Model/Config/Backend/Backorders.php b/app/code/Magento/CatalogInventory/Model/Config/Backend/Backorders.php index d5a890c3d54a3..383a8b911d8a1 100644 --- a/app/code/Magento/CatalogInventory/Model/Config/Backend/Backorders.php +++ b/app/code/Magento/CatalogInventory/Model/Config/Backend/Backorders.php @@ -28,6 +28,6 @@ public function afterSave() $this->stockIndex->rebuild(); $this->_stockIndexerProcessor->markIndexerAsInvalid(); } - return $this; + return parent::afterSave(); } } diff --git a/app/code/Magento/CatalogInventory/Model/Config/Backend/Managestock.php b/app/code/Magento/CatalogInventory/Model/Config/Backend/Managestock.php index 4b377112acc79..efbc166208a12 100644 --- a/app/code/Magento/CatalogInventory/Model/Config/Backend/Managestock.php +++ b/app/code/Magento/CatalogInventory/Model/Config/Backend/Managestock.php @@ -23,6 +23,6 @@ public function afterSave() $this->stockIndex->rebuild(); $this->_stockIndexerProcessor->markIndexerAsInvalid(); } - return $this; + return parent::afterSave(); } } diff --git a/app/code/Magento/CatalogInventory/Model/System/Config/Backend/Minsaleqty.php b/app/code/Magento/CatalogInventory/Model/System/Config/Backend/Minsaleqty.php index ea89069d8c56e..19a6877e505bb 100644 --- a/app/code/Magento/CatalogInventory/Model/System/Config/Backend/Minsaleqty.php +++ b/app/code/Magento/CatalogInventory/Model/System/Config/Backend/Minsaleqty.php @@ -21,6 +21,7 @@ class Minsaleqty extends \Magento\Framework\App\Config\Value * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry * @param \Magento\Framework\App\Config\ScopeConfigInterface $config + * @param \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList * @param \Magento\CatalogInventory\Helper\Minsaleqty $catalogInventoryMinsaleqty * @param \Magento\Framework\Model\ModelResource\AbstractResource $resource * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection @@ -30,13 +31,14 @@ public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\App\Config\ScopeConfigInterface $config, + \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList, \Magento\CatalogInventory\Helper\Minsaleqty $catalogInventoryMinsaleqty, \Magento\Framework\Model\ModelResource\AbstractResource $resource = null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, array $data = [] ) { $this->_catalogInventoryMinsaleqty = $catalogInventoryMinsaleqty; - parent::__construct($context, $registry, $config, $resource, $resourceCollection, $data); + parent::__construct($context, $registry, $config, $cacheTypeList, $resource, $resourceCollection, $data); } /** diff --git a/app/code/Magento/CatalogSearch/Model/Adminhtml/System/Config/Backend/Engine.php b/app/code/Magento/CatalogSearch/Model/Adminhtml/System/Config/Backend/Engine.php index cf56ff5dc490f..831a0ee804014 100644 --- a/app/code/Magento/CatalogSearch/Model/Adminhtml/System/Config/Backend/Engine.php +++ b/app/code/Magento/CatalogSearch/Model/Adminhtml/System/Config/Backend/Engine.php @@ -17,6 +17,7 @@ class Engine extends \Magento\Framework\App\Config\Value * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry * @param \Magento\Framework\App\Config\ScopeConfigInterface $config + * @param \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList * @param \Magento\Framework\Indexer\IndexerRegistry $indexerRegistry * @param \Magento\Framework\Model\ModelResource\AbstractResource $resource * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection @@ -26,13 +27,14 @@ public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\App\Config\ScopeConfigInterface $config, + \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList, \Magento\Framework\Indexer\IndexerRegistry $indexerRegistry, \Magento\Framework\Model\ModelResource\AbstractResource $resource = null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, array $data = [] ) { $this->indexerRegistry = $indexerRegistry; - parent::__construct($context, $registry, $config, $resource, $resourceCollection, $data); + parent::__construct($context, $registry, $config, $cacheTypeList, $resource, $resourceCollection, $data); } /** diff --git a/app/code/Magento/Config/Model/Config/Backend/Admin/Custom.php b/app/code/Magento/Config/Model/Config/Backend/Admin/Custom.php index 21ce20f6174f1..59bb6074d699e 100644 --- a/app/code/Magento/Config/Model/Config/Backend/Admin/Custom.php +++ b/app/code/Magento/Config/Model/Config/Backend/Admin/Custom.php @@ -58,6 +58,7 @@ class Custom extends \Magento\Framework\App\Config\Value * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry * @param \Magento\Framework\App\Config\ScopeConfigInterface $config + * @param \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList * @param \Magento\Framework\App\Config\Storage\WriterInterface $configWriter * @param \Magento\Framework\Model\ModelResource\AbstractResource $resource * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection @@ -67,13 +68,14 @@ public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\App\Config\ScopeConfigInterface $config, + \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList, \Magento\Framework\App\Config\Storage\WriterInterface $configWriter, \Magento\Framework\Model\ModelResource\AbstractResource $resource = null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, array $data = [] ) { $this->_configWriter = $configWriter; - parent::__construct($context, $registry, $config, $resource, $resourceCollection, $data); + parent::__construct($context, $registry, $config, $cacheTypeList, $resource, $resourceCollection, $data); } /** @@ -122,6 +124,6 @@ public function afterSave() ); } - return $this; + return parent::afterSave(); } } diff --git a/app/code/Magento/Config/Model/Config/Backend/Admin/Robots.php b/app/code/Magento/Config/Model/Config/Backend/Admin/Robots.php index 0fe5834b863f3..31df36606c6fe 100644 --- a/app/code/Magento/Config/Model/Config/Backend/Admin/Robots.php +++ b/app/code/Magento/Config/Model/Config/Backend/Admin/Robots.php @@ -27,6 +27,7 @@ class Robots extends \Magento\Framework\App\Config\Value * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry * @param \Magento\Framework\App\Config\ScopeConfigInterface $config + * @param \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList * @param \Magento\Framework\Filesystem $filesystem * @param \Magento\Framework\Model\ModelResource\AbstractResource $resource * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection @@ -36,12 +37,13 @@ public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\App\Config\ScopeConfigInterface $config, + \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList, \Magento\Framework\Filesystem $filesystem, \Magento\Framework\Model\ModelResource\AbstractResource $resource = null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, array $data = [] ) { - parent::__construct($context, $registry, $config, $resource, $resourceCollection, $data); + parent::__construct($context, $registry, $config, $cacheTypeList, $resource, $resourceCollection, $data); $this->_directory = $filesystem->getDirectoryWrite(DirectoryList::ROOT); $this->_file = 'robots.txt'; } diff --git a/app/code/Magento/Config/Model/Config/Backend/Admin/Usecustom.php b/app/code/Magento/Config/Model/Config/Backend/Admin/Usecustom.php index 2b2de392e7dd2..6b7a585dd351c 100644 --- a/app/code/Magento/Config/Model/Config/Backend/Admin/Usecustom.php +++ b/app/code/Magento/Config/Model/Config/Backend/Admin/Usecustom.php @@ -22,6 +22,7 @@ class Usecustom extends \Magento\Framework\App\Config\Value * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry * @param \Magento\Framework\App\Config\ScopeConfigInterface $config + * @param \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList * @param \Magento\Framework\App\Config\Storage\WriterInterface $configWriter * @param \Magento\Framework\Model\ModelResource\AbstractResource $resource * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection @@ -31,13 +32,14 @@ public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\App\Config\ScopeConfigInterface $config, + \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList, \Magento\Framework\App\Config\Storage\WriterInterface $configWriter, \Magento\Framework\Model\ModelResource\AbstractResource $resource = null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, array $data = [] ) { $this->_configWriter = $configWriter; - parent::__construct($context, $registry, $config, $resource, $resourceCollection, $data); + parent::__construct($context, $registry, $config, $cacheTypeList, $resource, $resourceCollection, $data); } /** @@ -81,6 +83,6 @@ public function afterSave() ); } - return $this; + return parent::afterSave(); } } diff --git a/app/code/Magento/Config/Model/Config/Backend/Admin/Usesecretkey.php b/app/code/Magento/Config/Model/Config/Backend/Admin/Usesecretkey.php index 49298cb928838..283cfc3eb63a6 100644 --- a/app/code/Magento/Config/Model/Config/Backend/Admin/Usesecretkey.php +++ b/app/code/Magento/Config/Model/Config/Backend/Admin/Usesecretkey.php @@ -20,6 +20,7 @@ class Usesecretkey extends \Magento\Framework\App\Config\Value * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry * @param \Magento\Framework\App\Config\ScopeConfigInterface $config + * @param \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList * @param \Magento\Backend\Model\UrlInterface $backendUrl * @param \Magento\Framework\Model\ModelResource\AbstractResource $resource * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection @@ -29,13 +30,14 @@ public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\App\Config\ScopeConfigInterface $config, + \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList, \Magento\Backend\Model\UrlInterface $backendUrl, \Magento\Framework\Model\ModelResource\AbstractResource $resource = null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, array $data = [] ) { $this->_backendUrl = $backendUrl; - parent::__construct($context, $registry, $config, $resource, $resourceCollection, $data); + parent::__construct($context, $registry, $config, $cacheTypeList, $resource, $resourceCollection, $data); } /** @@ -44,6 +46,6 @@ public function __construct( public function afterSave() { $this->_backendUrl->renewSecretUrls(); - return $this; + return parent::afterSave(); } } diff --git a/app/code/Magento/Config/Model/Config/Backend/Baseurl.php b/app/code/Magento/Config/Model/Config/Backend/Baseurl.php index 9f9db6d0a99c9..b066e0669d9c0 100644 --- a/app/code/Magento/Config/Model/Config/Backend/Baseurl.php +++ b/app/code/Magento/Config/Model/Config/Backend/Baseurl.php @@ -16,6 +16,7 @@ class Baseurl extends \Magento\Framework\App\Config\Value * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry * @param \Magento\Framework\App\Config\ScopeConfigInterface $config + * @param \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList * @param \Magento\Framework\View\Asset\MergeService $mergeService * @param \Magento\Framework\Model\ModelResource\AbstractResource $resource * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection @@ -25,13 +26,14 @@ public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\App\Config\ScopeConfigInterface $config, + \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList, \Magento\Framework\View\Asset\MergeService $mergeService, \Magento\Framework\Model\ModelResource\AbstractResource $resource = null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, array $data = [] ) { $this->_mergeService = $mergeService; - parent::__construct($context, $registry, $config, $resource, $resourceCollection, $data); + parent::__construct($context, $registry, $config, $cacheTypeList, $resource, $resourceCollection, $data); } /** @@ -198,7 +200,7 @@ private function _isFullyQualifiedUrl($value) /** * Clean compiled JS/CSS when updating url configuration settings * - * @return void + * @return $this */ public function afterSave() { @@ -212,5 +214,6 @@ public function afterSave() break; } } + return parent::afterSave(); } } diff --git a/app/code/Magento/Config/Model/Config/Backend/Currency/AbstractCurrency.php b/app/code/Magento/Config/Model/Config/Backend/Currency/AbstractCurrency.php index 02ffa58b6b2ab..42c589c06a991 100644 --- a/app/code/Magento/Config/Model/Config/Backend/Currency/AbstractCurrency.php +++ b/app/code/Magento/Config/Model/Config/Backend/Currency/AbstractCurrency.php @@ -15,37 +15,6 @@ abstract class AbstractCurrency extends \Magento\Framework\App\Config\Value { - /** - * Core store config - * - * @var \Magento\Framework\App\Config\ScopeConfigInterface - */ - protected $_scopeConfig; - - /** - * Constructor - * - * @param \Magento\Framework\Model\Context $context - * @param \Magento\Framework\Registry $registry - * @param \Magento\Framework\App\Config\ScopeConfigInterface $config - * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig - * @param \Magento\Framework\Model\ModelResource\AbstractResource $resource - * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection - * @param array $data - */ - public function __construct( - \Magento\Framework\Model\Context $context, - \Magento\Framework\Registry $registry, - \Magento\Framework\App\Config\ScopeConfigInterface $config, - \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, - \Magento\Framework\Model\ModelResource\AbstractResource $resource = null, - \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, - array $data = [] - ) { - $this->_scopeConfig = $scopeConfig; - parent::__construct($context, $registry, $config, $resource, $resourceCollection, $data); - } - /** * Retrieve allowed currencies for current scope * @@ -75,7 +44,7 @@ protected function _getInstalledCurrencies() { return explode( ',', - $this->_scopeConfig->getValue( + $this->_config->getValue( 'system/currency/installed', \Magento\Store\Model\ScopeInterface::SCOPE_STORE ) diff --git a/app/code/Magento/Config/Model/Config/Backend/Currency/Allow.php b/app/code/Magento/Config/Model/Config/Backend/Currency/Allow.php index f38db8cc6dd93..fecb071047272 100644 --- a/app/code/Magento/Config/Model/Config/Backend/Currency/Allow.php +++ b/app/code/Magento/Config/Model/Config/Backend/Currency/Allow.php @@ -21,7 +21,7 @@ class Allow extends AbstractCurrency * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry * @param \Magento\Framework\App\Config\ScopeConfigInterface $config - * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig + * @param \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList * @param \Magento\Framework\Locale\CurrencyInterface $localeCurrency * @param \Magento\Framework\Model\ModelResource\AbstractResource $resource * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection @@ -31,14 +31,14 @@ public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\App\Config\ScopeConfigInterface $config, - \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, + \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList, \Magento\Framework\Locale\CurrencyInterface $localeCurrency, \Magento\Framework\Model\ModelResource\AbstractResource $resource = null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, array $data = [] ) { $this->_localeCurrency = $localeCurrency; - parent::__construct($context, $registry, $config, $scopeConfig, $resource, $resourceCollection, $data); + parent::__construct($context, $registry, $config, $cacheTypeList, $resourceCollection, $resource, $data); } /** @@ -71,6 +71,6 @@ public function afterSave() throw new \Magento\Framework\Exception\LocalizedException(__(join("\n", $exceptions))); } - return $this; + return parent::afterSave(); } } diff --git a/app/code/Magento/Config/Model/Config/Backend/Currency/Base.php b/app/code/Magento/Config/Model/Config/Backend/Currency/Base.php index 8b000db011776..fe32b71564f34 100644 --- a/app/code/Magento/Config/Model/Config/Backend/Currency/Base.php +++ b/app/code/Magento/Config/Model/Config/Backend/Currency/Base.php @@ -19,7 +19,7 @@ class Base extends AbstractCurrency * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry * @param \Magento\Framework\App\Config\ScopeConfigInterface $config - * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig + * @param \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList * @param \Magento\Directory\Model\CurrencyFactory $currencyFactory * @param \Magento\Framework\Model\ModelResource\AbstractResource $resource * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection @@ -29,13 +29,13 @@ public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\App\Config\ScopeConfigInterface $config, - \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, + \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList, \Magento\Directory\Model\CurrencyFactory $currencyFactory, \Magento\Framework\Model\ModelResource\AbstractResource $resource = null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, array $data = [] ) { - parent::__construct($context, $registry, $config, $scopeConfig, $resource, $resourceCollection, $data); + parent::__construct($context, $registry, $config, $cacheTypeList, $resourceCollection, $resource, $data); $this->currencyFactory = $currencyFactory; } @@ -55,6 +55,6 @@ public function afterSave() } $this->currencyFactory->create()->saveRates([$value =>[$value => 1]]); - return $this; + return parent::afterSave(); } } diff --git a/app/code/Magento/Config/Model/Config/Backend/Currency/Cron.php b/app/code/Magento/Config/Model/Config/Backend/Currency/Cron.php index 2575a80ec7380..273a8accec1da 100644 --- a/app/code/Magento/Config/Model/Config/Backend/Currency/Cron.php +++ b/app/code/Magento/Config/Model/Config/Backend/Currency/Cron.php @@ -21,6 +21,7 @@ class Cron extends \Magento\Framework\App\Config\Value * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry * @param \Magento\Framework\App\Config\ScopeConfigInterface $config + * @param \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList * @param \Magento\Framework\App\Config\ValueFactory $configValueFactory * @param \Magento\Framework\Model\ModelResource\AbstractResource $resource * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection @@ -30,17 +31,18 @@ public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\App\Config\ScopeConfigInterface $config, + \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList, \Magento\Framework\App\Config\ValueFactory $configValueFactory, \Magento\Framework\Model\ModelResource\AbstractResource $resource = null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, array $data = [] ) { $this->_configValueFactory = $configValueFactory; - parent::__construct($context, $registry, $config, $resource, $resourceCollection, $data); + parent::__construct($context, $registry, $config, $cacheTypeList, $resource, $resourceCollection, $data); } /** - * @return void + * @return $this * @throws \Exception */ public function afterSave() @@ -69,5 +71,6 @@ public function afterSave() } catch (\Exception $e) { throw new \Exception(__('We can\'t save the Cron expression.')); } + return parent::afterSave(); } } diff --git a/app/code/Magento/Config/Model/Config/Backend/Currency/DefaultCurrency.php b/app/code/Magento/Config/Model/Config/Backend/Currency/DefaultCurrency.php index 35e8e5688ca0c..a086a674570ef 100644 --- a/app/code/Magento/Config/Model/Config/Backend/Currency/DefaultCurrency.php +++ b/app/code/Magento/Config/Model/Config/Backend/Currency/DefaultCurrency.php @@ -33,6 +33,6 @@ public function afterSave() ); } - return $this; + return parent::afterSave(); } } diff --git a/app/code/Magento/Config/Model/Config/Backend/Encrypted.php b/app/code/Magento/Config/Model/Config/Backend/Encrypted.php index 51a78e6f18873..d12edd3ffdbb9 100644 --- a/app/code/Magento/Config/Model/Config/Backend/Encrypted.php +++ b/app/code/Magento/Config/Model/Config/Backend/Encrypted.php @@ -22,6 +22,7 @@ class Encrypted extends \Magento\Framework\App\Config\Value implements * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry * @param \Magento\Framework\App\Config\ScopeConfigInterface $config + * @param \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList * @param \Magento\Framework\Encryption\EncryptorInterface $encryptor * @param \Magento\Framework\Model\ModelResource\AbstractResource $resource * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection @@ -31,13 +32,14 @@ public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\App\Config\ScopeConfigInterface $config, + \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList, \Magento\Framework\Encryption\EncryptorInterface $encryptor, \Magento\Framework\Model\ModelResource\AbstractResource $resource = null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, array $data = [] ) { $this->_encryptor = $encryptor; - parent::__construct($context, $registry, $config, $resource, $resourceCollection, $data); + parent::__construct($context, $registry, $config, $cacheTypeList, $resource, $resourceCollection, $data); } /** diff --git a/app/code/Magento/Config/Model/Config/Backend/File.php b/app/code/Magento/Config/Model/Config/Backend/File.php index 1b03ae15671fb..9496bc6ab3aa3 100644 --- a/app/code/Magento/Config/Model/Config/Backend/File.php +++ b/app/code/Magento/Config/Model/Config/Backend/File.php @@ -13,6 +13,7 @@ * System config file field backend model * * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ class File extends \Magento\Framework\App\Config\Value { @@ -47,6 +48,7 @@ class File extends \Magento\Framework\App\Config\Value * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry * @param \Magento\Framework\App\Config\ScopeConfigInterface $config + * @param \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList * @param \Magento\MediaStorage\Model\File\UploaderFactory $uploaderFactory * @param \Magento\Config\Model\Config\Backend\File\RequestData\RequestDataInterface $requestData * @param Filesystem $filesystem @@ -58,6 +60,7 @@ public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\App\Config\ScopeConfigInterface $config, + \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList, \Magento\MediaStorage\Model\File\UploaderFactory $uploaderFactory, \Magento\Config\Model\Config\Backend\File\RequestData\RequestDataInterface $requestData, Filesystem $filesystem, @@ -69,7 +72,7 @@ public function __construct( $this->_requestData = $requestData; $this->_filesystem = $filesystem; $this->_mediaDirectory = $filesystem->getDirectoryWrite(DirectoryList::MEDIA); - parent::__construct($context, $registry, $config, $resource, $resourceCollection, $data); + parent::__construct($context, $registry, $config, $cacheTypeList, $resource, $resourceCollection, $data); } /** diff --git a/app/code/Magento/Config/Model/Config/Backend/Image/Adapter.php b/app/code/Magento/Config/Model/Config/Backend/Image/Adapter.php index 486df64d2fcc4..a1f1fc2f8e969 100644 --- a/app/code/Magento/Config/Model/Config/Backend/Image/Adapter.php +++ b/app/code/Magento/Config/Model/Config/Backend/Image/Adapter.php @@ -22,6 +22,7 @@ class Adapter extends \Magento\Framework\App\Config\Value * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry * @param \Magento\Framework\App\Config\ScopeConfigInterface $config + * @param \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList * @param \Magento\Framework\Image\AdapterFactory $imageFactory * @param \Magento\Framework\Model\ModelResource\AbstractResource $resource * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection @@ -31,12 +32,13 @@ public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\App\Config\ScopeConfigInterface $config, + \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList, \Magento\Framework\Image\AdapterFactory $imageFactory, \Magento\Framework\Model\ModelResource\AbstractResource $resource = null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, array $data = [] ) { - parent::__construct($context, $registry, $config, $resource, $resourceCollection, $data); + parent::__construct($context, $registry, $config, $cacheTypeList, $resource, $resourceCollection, $data); $this->_imageFactory = $imageFactory; } diff --git a/app/code/Magento/Config/Model/Config/Backend/Locale.php b/app/code/Magento/Config/Model/Config/Backend/Locale.php index 6c7fca6df42e5..bed8303d776c0 100644 --- a/app/code/Magento/Config/Model/Config/Backend/Locale.php +++ b/app/code/Magento/Config/Model/Config/Backend/Locale.php @@ -37,6 +37,7 @@ class Locale extends \Magento\Framework\App\Config\Value * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry * @param \Magento\Framework\App\Config\ScopeConfigInterface $config + * @param \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList * @param \Magento\Config\Model\ResourceModel\Config\Data\CollectionFactory $configsFactory * @param \Magento\Store\Model\WebsiteFactory $websiteFactory * @param \Magento\Store\Model\StoreFactory $storeFactory @@ -51,6 +52,7 @@ public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\App\Config\ScopeConfigInterface $config, + \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList, \Magento\Config\Model\ResourceModel\Config\Data\CollectionFactory $configsFactory, \Magento\Store\Model\WebsiteFactory $websiteFactory, \Magento\Store\Model\StoreFactory $storeFactory, @@ -63,7 +65,7 @@ public function __construct( $this->_websiteFactory = $websiteFactory; $this->_storeFactory = $storeFactory; $this->_localeCurrency = $localeCurrency; - parent::__construct($context, $registry, $config, $resource, $resourceCollection, $data); + parent::__construct($context, $registry, $config, $cacheTypeList, $resource, $resourceCollection, $data); } /** @@ -120,6 +122,6 @@ public function afterSave() throw new \Magento\Framework\Exception\LocalizedException(__(join("\n", $exceptions))); } - return $this; + return parent::afterSave(); } } diff --git a/app/code/Magento/Config/Model/Config/Backend/Log/Cron.php b/app/code/Magento/Config/Model/Config/Backend/Log/Cron.php index 83ae49a6cf760..01eebb5ce2b4c 100644 --- a/app/code/Magento/Config/Model/Config/Backend/Log/Cron.php +++ b/app/code/Magento/Config/Model/Config/Backend/Log/Cron.php @@ -29,6 +29,7 @@ class Cron extends \Magento\Framework\App\Config\Value * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry * @param \Magento\Framework\App\Config\ScopeConfigInterface $config + * @param \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList * @param \Magento\Framework\App\Config\ValueFactory $configValueFactory * @param \Magento\Framework\Model\ModelResource\AbstractResource $resource * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection @@ -39,6 +40,7 @@ public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\App\Config\ScopeConfigInterface $config, + \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList, \Magento\Framework\App\Config\ValueFactory $configValueFactory, \Magento\Framework\Model\ModelResource\AbstractResource $resource = null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, @@ -47,13 +49,13 @@ public function __construct( ) { $this->_configValueFactory = $configValueFactory; $this->_runModelPath = $runModelPath; - parent::__construct($context, $registry, $config, $resource, $resourceCollection, $data); + parent::__construct($context, $registry, $config, $cacheTypeList, $resource, $resourceCollection, $data); } /** * Cron settings after save * - * @return void + * @return $this * @throws \Magento\Framework\Exception\LocalizedException */ public function afterSave() @@ -91,5 +93,6 @@ public function afterSave() } catch (\Exception $e) { throw new \Magento\Framework\Exception\LocalizedException(__('We can\'t save the Cron expression.')); } + return parent::afterSave(); } } diff --git a/app/code/Magento/Config/Model/Config/Backend/Secure.php b/app/code/Magento/Config/Model/Config/Backend/Secure.php index 7eab9b7846fb8..25ccf26b560ec 100644 --- a/app/code/Magento/Config/Model/Config/Backend/Secure.php +++ b/app/code/Magento/Config/Model/Config/Backend/Secure.php @@ -15,6 +15,7 @@ class Secure extends \Magento\Framework\App\Config\Value * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry * @param \Magento\Framework\App\Config\ScopeConfigInterface $config + * @param \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList * @param \Magento\Framework\View\Asset\MergeService $mergeService * @param \Magento\Framework\Model\ModelResource\AbstractResource $resource * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection @@ -24,24 +25,26 @@ public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\App\Config\ScopeConfigInterface $config, + \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList, \Magento\Framework\View\Asset\MergeService $mergeService, \Magento\Framework\Model\ModelResource\AbstractResource $resource = null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, array $data = [] ) { $this->_mergeService = $mergeService; - parent::__construct($context, $registry, $config, $resource, $resourceCollection, $data); + parent::__construct($context, $registry, $config, $cacheTypeList, $resource, $resourceCollection, $data); } /** * Clean compiled JS/CSS when updating configuration settings * - * @return void + * @return $this */ public function afterSave() { if ($this->isValueChanged()) { $this->_mergeService->cleanMergedJsCss(); } + return parent::afterSave(); } } diff --git a/app/code/Magento/Config/Model/Config/Backend/Serialized.php b/app/code/Magento/Config/Model/Config/Backend/Serialized.php index 28353119f9740..08cb70307420c 100644 --- a/app/code/Magento/Config/Model/Config/Backend/Serialized.php +++ b/app/code/Magento/Config/Model/Config/Backend/Serialized.php @@ -19,12 +19,13 @@ protected function _afterLoad() } /** - * @return void + * @return $this */ public function beforeSave() { if (is_array($this->getValue())) { $this->setValue(serialize($this->getValue())); } + return parent::beforeSave(); } } diff --git a/app/code/Magento/Config/Model/Config/Backend/Serialized/ArraySerialized.php b/app/code/Magento/Config/Model/Config/Backend/Serialized/ArraySerialized.php index cdfd0653ec789..2a012697da393 100644 --- a/app/code/Magento/Config/Model/Config/Backend/Serialized/ArraySerialized.php +++ b/app/code/Magento/Config/Model/Config/Backend/Serialized/ArraySerialized.php @@ -15,7 +15,7 @@ class ArraySerialized extends \Magento\Config\Model\Config\Backend\Serialized /** * Unset array element with '__empty' key * - * @return void + * @return $this */ public function beforeSave() { @@ -24,6 +24,6 @@ public function beforeSave() unset($value['__empty']); } $this->setValue($value); - parent::beforeSave(); + return parent::beforeSave(); } } diff --git a/app/code/Magento/Config/Model/Config/Backend/Store.php b/app/code/Magento/Config/Model/Config/Backend/Store.php index 85c10c62a1817..bf34f2aa09d07 100644 --- a/app/code/Magento/Config/Model/Config/Backend/Store.php +++ b/app/code/Magento/Config/Model/Config/Backend/Store.php @@ -20,6 +20,7 @@ class Store extends \Magento\Framework\App\Config\Value * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry * @param \Magento\Framework\App\Config\ScopeConfigInterface $config + * @param \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList * @param \Magento\Framework\App\Config\MutableScopeConfigInterface $mutableConfig * @param \Magento\Framework\Model\ModelResource\AbstractResource $resource * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection @@ -29,17 +30,18 @@ public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\App\Config\ScopeConfigInterface $config, + \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList, \Magento\Framework\App\Config\MutableScopeConfigInterface $mutableConfig, \Magento\Framework\Model\ModelResource\AbstractResource $resource = null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, array $data = [] ) { - parent::__construct($context, $registry, $config, $resource, $resourceCollection, $data); + parent::__construct($context, $registry, $config, $cacheTypeList, $resource, $resourceCollection, $data); $this->_mutableConfig = $mutableConfig; } /** - * @return void + * @return $this */ public function afterSave() { @@ -49,5 +51,6 @@ public function afterSave() \Magento\Store\Model\ScopeInterface::SCOPE_STORE ); $this->_cacheManager->clean(); + return parent::afterSave(); } } diff --git a/app/code/Magento/Config/Model/Config/Backend/Translate.php b/app/code/Magento/Config/Model/Config/Backend/Translate.php index e91a44e91aeb8..665a7e68e1a13 100644 --- a/app/code/Magento/Config/Model/Config/Backend/Translate.php +++ b/app/code/Magento/Config/Model/Config/Backend/Translate.php @@ -3,77 +3,24 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ +namespace Magento\Rss\Model\System\Config\Backend; /** - * System config translate inline fields backend model + * Cache cleaner backend model + * */ -namespace Magento\Config\Model\Config\Backend; - -class Translate extends \Magento\Framework\App\Config\Value +class Links extends \Magento\Framework\App\Config\Value { /** - * @var \Magento\Framework\App\Cache\TypeListInterface - */ - protected $_cacheTypeList; - - /** - * Path to config node with list of caches - * - * @var string - */ - const XML_PATH_INVALID_CACHES = 'dev/translate_inline/invalid_caches'; - - /** - * Core store config - * - * @var \Magento\Framework\App\Config\ScopeConfigInterface - */ - protected $_scopeConfig; - - /** - * Constructor - * - * @param \Magento\Framework\Model\Context $context - * @param \Magento\Framework\Registry $registry - * @param \Magento\Framework\App\Config\ScopeConfigInterface $config - * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig - * @param \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList - * @param \Magento\Framework\Model\ModelResource\AbstractResource $resource - * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection - * @param array $data - */ - public function __construct( - \Magento\Framework\Model\Context $context, - \Magento\Framework\Registry $registry, - \Magento\Framework\App\Config\ScopeConfigInterface $config, - \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, - \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList, - \Magento\Framework\Model\ModelResource\AbstractResource $resource = null, - \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, - array $data = [] - ) { - $this->_scopeConfig = $scopeConfig; - $this->_cacheTypeList = $cacheTypeList; - parent::__construct($context, $registry, $config, $resource, $resourceCollection, $data); - } - - /** - * Set status 'invalidate' for blocks and other output caches + * Invalidate cache type, when value was changed * * @return $this */ public function afterSave() { - $types = array_keys( - $this->_scopeConfig->getValue( - self::XML_PATH_INVALID_CACHES, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE - ) - ); if ($this->isValueChanged()) { - $this->_cacheTypeList->invalidate($types); + $this->cacheTypeList->invalidate(\Magento\Framework\View\Element\AbstractBlock::CACHE_GROUP); } - - return $this; + return parent::afterSave(); } } diff --git a/app/code/Magento/Config/Test/Unit/Model/Config/Backend/BaseurlTest.php b/app/code/Magento/Config/Test/Unit/Model/Config/Backend/BaseurlTest.php index 38b195ac3363b..8f9d418356e0b 100644 --- a/app/code/Magento/Config/Test/Unit/Model/Config/Backend/BaseurlTest.php +++ b/app/code/Magento/Config/Test/Unit/Model/Config/Backend/BaseurlTest.php @@ -5,6 +5,7 @@ */ namespace Magento\Config\Test\Unit\Model\Config\Backend; +use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; use Magento\Store\Model\StoreManagerInterface; use Magento\Store\Model\Store; @@ -12,25 +13,8 @@ class BaseurlTest extends \PHPUnit_Framework_TestCase { public function testSaveMergedJsCssMustBeCleaned() { - $eventDispatcher = $this->getMock('Magento\Framework\Event\ManagerInterface', [], [], '', false); - $appState = $this->getMock('Magento\Framework\App\State', [], [], '', false); - $cacheManager = $this->getMock('Magento\Framework\App\CacheInterface'); - $logger = $this->getMock('Psr\Log\LoggerInterface'); - $actionValidatorMock = $this->getMock( - 'Magento\Framework\Model\ActionValidator\RemoveAction', - [], - [], - '', - false - ); - $context = new \Magento\Framework\Model\Context( - $logger, - $eventDispatcher, - $cacheManager, - $appState, - $actionValidatorMock - ); + $context = (new ObjectManager($this))->getObject('Magento\Framework\Model\Context'); $resource = $this->getMock('Magento\Config\Model\ResourceModel\Config\Data', [], [], '', false); $resource->expects($this->any())->method('addCommitCallback')->will($this->returnValue($resource)); @@ -40,12 +24,18 @@ public function testSaveMergedJsCssMustBeCleaned() $mergeService = $this->getMock('Magento\Framework\View\Asset\MergeService', [], [], '', false); $coreRegistry = $this->getMock('Magento\Framework\Registry', [], [], '', false); $coreConfig = $this->getMock('Magento\Framework\App\Config\ScopeConfigInterface'); - + $cacheTypeListMock = $this->getMockBuilder('Magento\Framework\App\Cache\TypeListInterface') + ->disableOriginalConstructor() + ->getMock(); $model = $this->getMock( 'Magento\Config\Model\Config\Backend\Baseurl', ['getOldValue'], - [$context, $coreRegistry, $coreConfig, $mergeService, $resource, $resourceCollection] + [$context, $coreRegistry, $coreConfig, $cacheTypeListMock, $mergeService, $resource, $resourceCollection] ); + $cacheTypeListMock->expects($this->once()) + ->method('invalidate') + ->with(\Magento\Framework\App\Cache\Type\Config::TYPE_IDENTIFIER) + ->willReturn($model); $mergeService->expects($this->once())->method('cleanMergedJsCss'); $model->setValue('http://example.com/')->setPath(Store::XML_PATH_UNSECURE_BASE_URL); diff --git a/app/code/Magento/Config/Test/Unit/Model/Config/Backend/SecureTest.php b/app/code/Magento/Config/Test/Unit/Model/Config/Backend/SecureTest.php index 25280b8967d64..16bd95fa8250e 100644 --- a/app/code/Magento/Config/Test/Unit/Model/Config/Backend/SecureTest.php +++ b/app/code/Magento/Config/Test/Unit/Model/Config/Backend/SecureTest.php @@ -5,28 +5,13 @@ */ namespace Magento\Config\Test\Unit\Model\Config\Backend; +use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; + class SecureTest extends \PHPUnit_Framework_TestCase { public function testSaveMergedJsCssMustBeCleaned() { - $eventDispatcher = $this->getMock('Magento\Framework\Event\ManagerInterface', [], [], '', false); - $appState = $this->getMock('Magento\Framework\App\State', [], [], '', false); - $cacheManager = $this->getMock('Magento\Framework\App\CacheInterface'); - $logger = $this->getMock('Psr\Log\LoggerInterface'); - $actionValidatorMock = $this->getMock( - '\Magento\Framework\Model\ActionValidator\RemoveAction', - [], - [], - '', - false - ); - $context = new \Magento\Framework\Model\Context( - $logger, - $eventDispatcher, - $cacheManager, - $appState, - $actionValidatorMock - ); + $context = (new ObjectManager($this))->getObject('Magento\Framework\Model\Context'); $resource = $this->getMock('Magento\Config\Model\ResourceModel\Config\Data', [], [], '', false); $resource->expects($this->any())->method('addCommitCallback')->will($this->returnValue($resource)); @@ -36,12 +21,19 @@ public function testSaveMergedJsCssMustBeCleaned() $mergeService = $this->getMock('Magento\Framework\View\Asset\MergeService', [], [], '', false); $coreRegistry = $this->getMock('Magento\Framework\Registry', [], [], '', false); $coreConfig = $this->getMock('Magento\Framework\App\Config\ScopeConfigInterface'); + $cacheTypeListMock = $this->getMockBuilder('Magento\Framework\App\Cache\TypeListInterface') + ->disableOriginalConstructor() + ->getMock(); $model = $this->getMock( 'Magento\Config\Model\Config\Backend\Secure', ['getOldValue'], - [$context, $coreRegistry, $coreConfig, $mergeService, $resource, $resourceCollection] + [$context, $coreRegistry, $coreConfig, $cacheTypeListMock, $mergeService, $resource, $resourceCollection] ); + $cacheTypeListMock->expects($this->once()) + ->method('invalidate') + ->with(\Magento\Framework\App\Cache\Type\Config::TYPE_IDENTIFIER) + ->willReturn($model); $mergeService->expects($this->once())->method('cleanMergedJsCss'); $model->setValue('new_value'); diff --git a/app/code/Magento/Contact/Test/Unit/Model/System/Config/Backend/LinksTest.php b/app/code/Magento/Contact/Test/Unit/Model/System/Config/Backend/LinksTest.php index 5a2c469bf10fc..4ed7d5552349d 100644 --- a/app/code/Magento/Contact/Test/Unit/Model/System/Config/Backend/LinksTest.php +++ b/app/code/Magento/Contact/Test/Unit/Model/System/Config/Backend/LinksTest.php @@ -5,6 +5,8 @@ */ namespace Magento\Contact\Test\Unit\Model\System\Config\Backend; +use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; + class LinksTest extends \PHPUnit_Framework_TestCase { /** @@ -14,13 +16,7 @@ class LinksTest extends \PHPUnit_Framework_TestCase public function setUp() { - $this->_model = new \Magento\Contact\Model\System\Config\Backend\Links( - $this->getMock('\Magento\Framework\Model\Context', [], [], '', false), - $this->getMock('\Magento\Framework\Registry', [], [], '', false), - $this->getMockForAbstractClass('\Magento\Framework\App\Config\ScopeConfigInterface', [], '', false), - $this->getMockForAbstractClass('\Magento\Framework\Model\ModelResource\AbstractResource', [], '', false), - $this->getMock('\Magento\Framework\Data\Collection\AbstractDb', [], [], '', false) - ); + $this->_model = (new ObjectManager($this))->getObject('Magento\Contact\Model\System\Config\Backend\Links'); } public function testGetIdentities() diff --git a/app/code/Magento/Cookie/Model/Config/Backend/Domain.php b/app/code/Magento/Cookie/Model/Config/Backend/Domain.php index 0d8fb666c7506..d656941e6dad2 100644 --- a/app/code/Magento/Cookie/Model/Config/Backend/Domain.php +++ b/app/code/Magento/Cookie/Model/Config/Backend/Domain.php @@ -17,6 +17,7 @@ class Domain extends \Magento\Framework\App\Config\Value * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry * @param \Magento\Framework\App\Config\ScopeConfigInterface $config + * @param \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList * @param \Magento\Framework\Session\Config\Validator\CookieDomainValidator $configValidator * @param \Magento\Framework\Model\ModelResource\AbstractResource $resource * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection @@ -27,13 +28,14 @@ public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\App\Config\ScopeConfigInterface $config, + \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList, \Magento\Framework\Session\Config\Validator\CookieDomainValidator $configValidator, \Magento\Framework\Model\ModelResource\AbstractResource $resource = null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, array $data = [] ) { $this->configValidator = $configValidator; - parent::__construct($context, $registry, $config, $resource, $resourceCollection, $data); + parent::__construct($context, $registry, $config, $cacheTypeList, $resource, $resourceCollection, $data); } /** diff --git a/app/code/Magento/Cookie/Model/Config/Backend/Lifetime.php b/app/code/Magento/Cookie/Model/Config/Backend/Lifetime.php index 3170aadb8f597..b5b5a4d3ec3db 100644 --- a/app/code/Magento/Cookie/Model/Config/Backend/Lifetime.php +++ b/app/code/Magento/Cookie/Model/Config/Backend/Lifetime.php @@ -17,6 +17,7 @@ class Lifetime extends \Magento\Framework\App\Config\Value * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry * @param \Magento\Framework\App\Config\ScopeConfigInterface $config + * @param \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList * @param \Magento\Framework\Session\Config\Validator\CookieLifetimeValidator $configValidator * @param \Magento\Framework\Model\ModelResource\AbstractResource $resource * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection @@ -27,19 +28,20 @@ public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\App\Config\ScopeConfigInterface $config, + \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList, \Magento\Framework\Session\Config\Validator\CookieLifetimeValidator $configValidator, \Magento\Framework\Model\ModelResource\AbstractResource $resource = null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, array $data = [] ) { $this->configValidator = $configValidator; - parent::__construct($context, $registry, $config, $resource, $resourceCollection, $data); + parent::__construct($context, $registry, $config, $cacheTypeList, $resource, $resourceCollection, $data); } /** * Validate a domain name value * - * @return void + * @return $this * @throws \Magento\Framework\Exception\LocalizedException */ public function beforeSave() @@ -50,5 +52,6 @@ public function beforeSave() $msg = __('Invalid cookie lifetime: ' . join('; ', $this->configValidator->getMessages())); throw new \Magento\Framework\Exception\LocalizedException($msg); } + return parent::beforeSave(); } } diff --git a/app/code/Magento/Cookie/Model/Config/Backend/Path.php b/app/code/Magento/Cookie/Model/Config/Backend/Path.php index 7130085fbd8e7..bc2661e46573b 100644 --- a/app/code/Magento/Cookie/Model/Config/Backend/Path.php +++ b/app/code/Magento/Cookie/Model/Config/Backend/Path.php @@ -17,6 +17,7 @@ class Path extends \Magento\Framework\App\Config\Value * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry * @param \Magento\Framework\App\Config\ScopeConfigInterface $config + * @param \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList * @param \Magento\Framework\Session\Config\Validator\CookiePathValidator $configValidator * @param \Magento\Framework\Model\ModelResource\AbstractResource $resource * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection @@ -27,13 +28,14 @@ public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\App\Config\ScopeConfigInterface $config, + \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList, \Magento\Framework\Session\Config\Validator\CookiePathValidator $configValidator, \Magento\Framework\Model\ModelResource\AbstractResource $resource = null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, array $data = [] ) { $this->configValidator = $configValidator; - parent::__construct($context, $registry, $config, $resource, $resourceCollection, $data); + parent::__construct($context, $registry, $config, $cacheTypeList, $resource, $resourceCollection, $data); } /** diff --git a/app/code/Magento/Cron/Model/Config/Backend/Product/Alert.php b/app/code/Magento/Cron/Model/Config/Backend/Product/Alert.php index 7427d72f392fc..fc1989ef2614c 100644 --- a/app/code/Magento/Cron/Model/Config/Backend/Product/Alert.php +++ b/app/code/Magento/Cron/Model/Config/Backend/Product/Alert.php @@ -37,6 +37,7 @@ class Alert extends \Magento\Framework\App\Config\Value * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry * @param \Magento\Framework\App\Config\ScopeConfigInterface $config + * @param \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList * @param \Magento\Framework\App\Config\ValueFactory $configValueFactory * @param \Magento\Framework\Model\ModelResource\AbstractResource $resource * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection @@ -47,6 +48,7 @@ public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\App\Config\ScopeConfigInterface $config, + \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList, \Magento\Framework\App\Config\ValueFactory $configValueFactory, \Magento\Framework\Model\ModelResource\AbstractResource $resource = null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, @@ -55,11 +57,13 @@ public function __construct( ) { $this->_runModelPath = $runModelPath; $this->_configValueFactory = $configValueFactory; - parent::__construct($context, $registry, $config, $resource, $resourceCollection, $data); + parent::__construct($context, $registry, $config, $cacheTypeList, $resource, $resourceCollection, $data); } /** - * @return void + * {@inheritdoc} + * + * @return $this * @throws \Exception */ public function afterSave() @@ -97,5 +101,7 @@ public function afterSave() } catch (\Exception $e) { throw new \Exception(__('We can\'t save the cron expression.')); } + + return parent::afterSave(); } } diff --git a/app/code/Magento/Cron/Model/Config/Backend/Sitemap.php b/app/code/Magento/Cron/Model/Config/Backend/Sitemap.php index c49176ab6256b..13e59f4d73062 100644 --- a/app/code/Magento/Cron/Model/Config/Backend/Sitemap.php +++ b/app/code/Magento/Cron/Model/Config/Backend/Sitemap.php @@ -37,6 +37,7 @@ class Sitemap extends \Magento\Framework\App\Config\Value * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry * @param \Magento\Framework\App\Config\ScopeConfigInterface $config + * @param \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList * @param \Magento\Framework\App\Config\ValueFactory $configValueFactory * @param \Magento\Framework\Model\ModelResource\AbstractResource $resource * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection @@ -47,6 +48,7 @@ public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\App\Config\ScopeConfigInterface $config, + \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList, \Magento\Framework\App\Config\ValueFactory $configValueFactory, \Magento\Framework\Model\ModelResource\AbstractResource $resource = null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, @@ -55,11 +57,11 @@ public function __construct( ) { $this->_runModelPath = $runModelPath; $this->_configValueFactory = $configValueFactory; - parent::__construct($context, $registry, $config, $resource, $resourceCollection, $data); + parent::__construct($context, $registry, $config, $cacheTypeList, $resource, $resourceCollection, $data); } /** - * @return void + * @return $this * @throws \Exception */ public function afterSave() @@ -97,5 +99,6 @@ public function afterSave() } catch (\Exception $e) { throw new \Exception(__('We can\'t save the cron expression.')); } + return parent::afterSave(); } } diff --git a/app/code/Magento/Customer/Model/Config/Backend/Address/Street.php b/app/code/Magento/Customer/Model/Config/Backend/Address/Street.php index 014c25e8ea906..dd149276adfbe 100644 --- a/app/code/Magento/Customer/Model/Config/Backend/Address/Street.php +++ b/app/code/Magento/Customer/Model/Config/Backend/Address/Street.php @@ -26,6 +26,7 @@ class Street extends \Magento\Framework\App\Config\Value * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry * @param \Magento\Framework\App\Config\ScopeConfigInterface $config + * @param \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList * @param \Magento\Store\Model\StoreManagerInterface $storeManager * @param \Magento\Eav\Model\Config $eavConfig * @param \Magento\Framework\Model\ModelResource\AbstractResource $resource @@ -36,6 +37,7 @@ public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\App\Config\ScopeConfigInterface $config, + \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList, \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Eav\Model\Config $eavConfig, \Magento\Framework\Model\ModelResource\AbstractResource $resource = null, @@ -43,7 +45,7 @@ public function __construct( array $data = [] ) { $this->_eavConfig = $eavConfig; - parent::__construct($context, $registry, $config, $resource, $resourceCollection, $data); + parent::__construct($context, $registry, $config, $cacheTypeList, $resource, $resourceCollection, $data); $this->_storeManager = $storeManager; } @@ -71,7 +73,7 @@ public function afterSave() break; } $attribute->save(); - return $this; + return parent::afterSave(); } /** diff --git a/app/code/Magento/Customer/Model/Config/Backend/CreateAccount/DisableAutoGroupAssignDefault.php b/app/code/Magento/Customer/Model/Config/Backend/CreateAccount/DisableAutoGroupAssignDefault.php index 2c39ad5de0097..363fe4cd200a2 100644 --- a/app/code/Magento/Customer/Model/Config/Backend/CreateAccount/DisableAutoGroupAssignDefault.php +++ b/app/code/Magento/Customer/Model/Config/Backend/CreateAccount/DisableAutoGroupAssignDefault.php @@ -16,6 +16,7 @@ class DisableAutoGroupAssignDefault extends \Magento\Framework\App\Config\Value * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry * @param \Magento\Framework\App\Config\ScopeConfigInterface $config + * @param \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList * @param \Magento\Eav\Model\Config $eavConfig * @param \Magento\Framework\Model\ModelResource\AbstractResource $resource * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection @@ -25,13 +26,14 @@ public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\App\Config\ScopeConfigInterface $config, + \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList, \Magento\Eav\Model\Config $eavConfig, \Magento\Framework\Model\ModelResource\AbstractResource $resource = null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, array $data = [] ) { $this->eavConfig = $eavConfig; - parent::__construct($context, $registry, $config, $resource, $resourceCollection, $data); + parent::__construct($context, $registry, $config, $cacheTypeList, $resource, $resourceCollection, $data); } /** diff --git a/app/code/Magento/Customer/Model/Config/Backend/Show/Customer.php b/app/code/Magento/Customer/Model/Config/Backend/Show/Customer.php index 2957d9ae35f98..a4a9b336e9c56 100644 --- a/app/code/Magento/Customer/Model/Config/Backend/Show/Customer.php +++ b/app/code/Magento/Customer/Model/Config/Backend/Show/Customer.php @@ -26,6 +26,7 @@ class Customer extends \Magento\Framework\App\Config\Value * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry * @param \Magento\Framework\App\Config\ScopeConfigInterface $config + * @param \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList * @param \Magento\Store\Model\StoreManagerInterface $storeManager * @param \Magento\Eav\Model\Config $eavConfig * @param \Magento\Framework\Model\ModelResource\AbstractResource $resource @@ -36,6 +37,7 @@ public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\App\Config\ScopeConfigInterface $config, + \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList, \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Eav\Model\Config $eavConfig, \Magento\Framework\Model\ModelResource\AbstractResource $resource = null, @@ -43,7 +45,7 @@ public function __construct( array $data = [] ) { $this->_eavConfig = $eavConfig; - parent::__construct($context, $registry, $config, $resource, $resourceCollection, $data); + parent::__construct($context, $registry, $config, $cacheTypeList, $resource, $resourceCollection, $data); $this->storeManager = $storeManager; } diff --git a/app/code/Magento/Customer/Model/Config/Share.php b/app/code/Magento/Customer/Model/Config/Share.php index 5c8010c95b24e..f7e6be108a9b0 100644 --- a/app/code/Magento/Customer/Model/Config/Share.php +++ b/app/code/Magento/Customer/Model/Config/Share.php @@ -40,6 +40,7 @@ class Share extends \Magento\Framework\App\Config\Value implements \Magento\Fram * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry * @param \Magento\Framework\App\Config\ScopeConfigInterface $config + * @param \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList * @param \Magento\Store\Model\StoreManagerInterface $storeManager * @param \Magento\Customer\Model\ResourceModel\Customer $customerResource * @param \Magento\Framework\Model\ModelResource\AbstractResource $resource @@ -50,6 +51,7 @@ public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\App\Config\ScopeConfigInterface $config, + \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList, \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Customer\Model\ResourceModel\Customer $customerResource, \Magento\Framework\Model\ModelResource\AbstractResource $resource = null, @@ -58,7 +60,7 @@ public function __construct( ) { $this->_storeManager = $storeManager; $this->_customerResource = $customerResource; - parent::__construct($context, $registry, $config, $resource, $resourceCollection, $data); + parent::__construct($context, $registry, $config, $cacheTypeList, $resource, $resourceCollection, $data); } /** diff --git a/app/code/Magento/Developer/Model/Config/Backend/AllowedIps.php b/app/code/Magento/Developer/Model/Config/Backend/AllowedIps.php index e4552761129ea..1985206735325 100644 --- a/app/code/Magento/Developer/Model/Config/Backend/AllowedIps.php +++ b/app/code/Magento/Developer/Model/Config/Backend/AllowedIps.php @@ -30,6 +30,7 @@ class AllowedIps extends \Magento\Framework\App\Config\Value * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry * @param \Magento\Framework\App\Config\ScopeConfigInterface $config + * @param \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList * @param \Magento\Framework\Message\ManagerInterface $messageManager * @param \Magento\Framework\Escaper $escaper * @param \Magento\Framework\Model\ModelResource\AbstractResource $resource @@ -40,6 +41,7 @@ public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\App\Config\ScopeConfigInterface $config, + \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList, \Magento\Framework\Message\ManagerInterface $messageManager, \Magento\Framework\Escaper $escaper, \Magento\Framework\Model\ModelResource\AbstractResource $resource = null, @@ -48,7 +50,7 @@ public function __construct( ) { $this->messageManager = $messageManager; $this->escaper = $escaper; - parent::__construct($context, $registry, $config, $resource, $resourceCollection, $data); + parent::__construct($context, $registry, $config, $cacheTypeList, $resource, $resourceCollection, $data); } /** diff --git a/app/code/Magento/GoogleAdwords/Model/Config/Backend/AbstractConversion.php b/app/code/Magento/GoogleAdwords/Model/Config/Backend/AbstractConversion.php index f072d2114d675..f70ffd207ddef 100644 --- a/app/code/Magento/GoogleAdwords/Model/Config/Backend/AbstractConversion.php +++ b/app/code/Magento/GoogleAdwords/Model/Config/Backend/AbstractConversion.php @@ -26,6 +26,7 @@ abstract class AbstractConversion extends \Magento\Framework\App\Config\Value * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry * @param \Magento\Framework\App\Config\ScopeConfigInterface $config + * @param \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList * @param \Magento\Framework\Validator\DataObjectFactory $validatorCompositeFactory * @param \Magento\GoogleAdwords\Model\Validator\Factory $validatorFactory * @param \Magento\Framework\Model\ModelResource\AbstractResource $resource @@ -36,13 +37,14 @@ public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\App\Config\ScopeConfigInterface $config, + \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList, \Magento\Framework\Validator\DataObjectFactory $validatorCompositeFactory, \Magento\GoogleAdwords\Model\Validator\Factory $validatorFactory, \Magento\Framework\Model\ModelResource\AbstractResource $resource = null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, array $data = [] ) { - parent::__construct($context, $registry, $config, $resource, $resourceCollection, $data); + parent::__construct($context, $registry, $config, $cacheTypeList, $resource, $resourceCollection, $data); $this->_validatorFactory = $validatorFactory; $this->_validatorComposite = $validatorCompositeFactory->create(); diff --git a/app/code/Magento/MediaStorage/Model/Config/Backend/Storage/Media/Database.php b/app/code/Magento/MediaStorage/Model/Config/Backend/Storage/Media/Database.php index 95f4d6c21658e..0b1ebbd8317f1 100644 --- a/app/code/Magento/MediaStorage/Model/Config/Backend/Storage/Media/Database.php +++ b/app/code/Magento/MediaStorage/Model/Config/Backend/Storage/Media/Database.php @@ -18,6 +18,7 @@ class Database extends \Magento\Framework\App\Config\Value * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry * @param \Magento\Framework\App\Config\ScopeConfigInterface $config + * @param \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList * @param \Magento\MediaStorage\Helper\File\Storage $coreFileStorage * @param \Magento\Framework\Model\ModelResource\AbstractResource $resource * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection @@ -27,13 +28,14 @@ public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\App\Config\ScopeConfigInterface $config, + \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList, \Magento\MediaStorage\Helper\File\Storage $coreFileStorage, \Magento\Framework\Model\ModelResource\AbstractResource $resource = null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, array $data = [] ) { $this->_coreFileStorage = $coreFileStorage; - parent::__construct($context, $registry, $config, $resource, $resourceCollection, $data); + parent::__construct($context, $registry, $config, $cacheTypeList, $resource, $resourceCollection, $data); } /** @@ -46,6 +48,6 @@ public function afterSave() $helper = $this->_coreFileStorage; $helper->getStorageModel(null, ['init' => true]); - return $this; + return parent::afterSave(); } } diff --git a/app/code/Magento/OfflineShipping/Model/Config/Backend/Tablerate.php b/app/code/Magento/OfflineShipping/Model/Config/Backend/Tablerate.php index e48b75956b3c4..605afa7583375 100644 --- a/app/code/Magento/OfflineShipping/Model/Config/Backend/Tablerate.php +++ b/app/code/Magento/OfflineShipping/Model/Config/Backend/Tablerate.php @@ -23,6 +23,7 @@ class Tablerate extends \Magento\Framework\App\Config\Value * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry * @param \Magento\Framework\App\Config\ScopeConfigInterface $config + * @param \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList * @param \Magento\OfflineShipping\Model\ResourceModel\Carrier\TablerateFactory $tablerateFactory * @param \Magento\Framework\Model\ModelResource\AbstractResource $resource * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection @@ -32,22 +33,24 @@ public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\App\Config\ScopeConfigInterface $config, + \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList, \Magento\OfflineShipping\Model\ResourceModel\Carrier\TablerateFactory $tablerateFactory, \Magento\Framework\Model\ModelResource\AbstractResource $resource = null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, array $data = [] ) { $this->_tablerateFactory = $tablerateFactory; - parent::__construct($context, $registry, $config, $resource, $resourceCollection, $data); + parent::__construct($context, $registry, $config, $cacheTypeList, $resource, $resourceCollection, $data); } /** - * @return \Magento\Framework\Model\AbstractModel|void + * @return $this */ public function afterSave() { /** @var \Magento\OfflineShipping\Model\ResourceModel\Carrier\Tablerate $tableRate */ $tableRate = $this->_tablerateFactory->create(); $tableRate->uploadAndImport($this); + return parent::afterSave(); } } diff --git a/app/code/Magento/Paypal/Model/System/Config/Backend/Cert.php b/app/code/Magento/Paypal/Model/System/Config/Backend/Cert.php index 5edc101cc02e8..48569dd3bc333 100644 --- a/app/code/Magento/Paypal/Model/System/Config/Backend/Cert.php +++ b/app/code/Magento/Paypal/Model/System/Config/Backend/Cert.php @@ -10,6 +10,8 @@ /** * Backend model for saving certificate file in case of using certificate based authentication + * + * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ class Cert extends \Magento\Framework\App\Config\Value { @@ -32,6 +34,7 @@ class Cert extends \Magento\Framework\App\Config\Value * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry * @param \Magento\Framework\App\Config\ScopeConfigInterface $config + * @param \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList * @param \Magento\Paypal\Model\CertFactory $certFactory * @param \Magento\Framework\Encryption\EncryptorInterface $encryptor * @param \Magento\Framework\Filesystem $filesystem @@ -43,6 +46,7 @@ public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\App\Config\ScopeConfigInterface $config, + \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList, \Magento\Paypal\Model\CertFactory $certFactory, \Magento\Framework\Encryption\EncryptorInterface $encryptor, \Magento\Framework\Filesystem $filesystem, @@ -53,7 +57,7 @@ public function __construct( $this->_certFactory = $certFactory; $this->_encryptor = $encryptor; $this->_tmpDirectory = $filesystem->getDirectoryRead(DirectoryList::SYS_TMP); - parent::__construct($context, $registry, $config, $resource, $resourceCollection, $data); + parent::__construct($context, $registry, $config, $cacheTypeList, $resource, $resourceCollection, $data); } /** diff --git a/app/code/Magento/Paypal/Model/System/Config/Backend/Cron.php b/app/code/Magento/Paypal/Model/System/Config/Backend/Cron.php index dda1f59655900..0603fe3ee40ef 100644 --- a/app/code/Magento/Paypal/Model/System/Config/Backend/Cron.php +++ b/app/code/Magento/Paypal/Model/System/Config/Backend/Cron.php @@ -20,6 +20,7 @@ class Cron extends \Magento\Framework\App\Config\Value * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry * @param \Magento\Framework\App\Config\ScopeConfigInterface $config + * @param \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList * @param \Magento\Framework\App\Config\ValueFactory $configValueFactory * @param \Magento\Framework\Model\ModelResource\AbstractResource $resource * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection @@ -29,13 +30,14 @@ public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\App\Config\ScopeConfigInterface $config, + \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList, \Magento\Framework\App\Config\ValueFactory $configValueFactory, \Magento\Framework\Model\ModelResource\AbstractResource $resource = null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, array $data = [] ) { $this->_configValueFactory = $configValueFactory; - parent::__construct($context, $registry, $config, $resource, $resourceCollection, $data); + parent::__construct($context, $registry, $config, $cacheTypeList, $resource, $resourceCollection, $data); } /** diff --git a/app/code/Magento/Paypal/Model/System/Config/Backend/MerchantCountry.php b/app/code/Magento/Paypal/Model/System/Config/Backend/MerchantCountry.php index bef8a6e42b448..d02e68e1bf026 100644 --- a/app/code/Magento/Paypal/Model/System/Config/Backend/MerchantCountry.php +++ b/app/code/Magento/Paypal/Model/System/Config/Backend/MerchantCountry.php @@ -26,6 +26,7 @@ class MerchantCountry extends \Magento\Framework\App\Config\Value * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry * @param \Magento\Framework\App\Config\ScopeConfigInterface $config + * @param \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList * @param \Magento\Store\Model\StoreManagerInterface $storeManager * @param \Magento\Directory\Helper\Data $directoryHelper * @param \Magento\Framework\Model\ModelResource\AbstractResource $resource @@ -36,6 +37,7 @@ public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\App\Config\ScopeConfigInterface $config, + \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList, \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Directory\Helper\Data $directoryHelper, \Magento\Framework\Model\ModelResource\AbstractResource $resource = null, @@ -43,7 +45,7 @@ public function __construct( array $data = [] ) { $this->directoryHelper = $directoryHelper; - parent::__construct($context, $registry, $config, $resource, $resourceCollection, $data); + parent::__construct($context, $registry, $config, $cacheTypeList, $resource, $resourceCollection, $data); $this->_storeManager = $storeManager; } diff --git a/app/code/Magento/Rss/Model/System/Config/Backend/Links.php b/app/code/Magento/Rss/Model/System/Config/Backend/Links.php index c86f176a373be..665a7e68e1a13 100644 --- a/app/code/Magento/Rss/Model/System/Config/Backend/Links.php +++ b/app/code/Magento/Rss/Model/System/Config/Backend/Links.php @@ -11,42 +11,16 @@ */ class Links extends \Magento\Framework\App\Config\Value { - /** - * @var \Magento\Framework\App\Cache\TypeListInterface - */ - protected $_cacheTypeList; - - /** - * @param \Magento\Framework\Model\Context $context - * @param \Magento\Framework\Registry $registry - * @param \Magento\Framework\App\Config\ScopeConfigInterface $config - * @param \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList - * @param \Magento\Framework\Model\ModelResource\AbstractResource $resource - * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection - * @param array $data - */ - public function __construct( - \Magento\Framework\Model\Context $context, - \Magento\Framework\Registry $registry, - \Magento\Framework\App\Config\ScopeConfigInterface $config, - \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList, - \Magento\Framework\Model\ModelResource\AbstractResource $resource = null, - \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, - array $data = [] - ) { - $this->_cacheTypeList = $cacheTypeList; - parent::__construct($context, $registry, $config, $resource, $resourceCollection, $data); - } - /** * Invalidate cache type, when value was changed * - * @return void + * @return $this */ public function afterSave() { if ($this->isValueChanged()) { - $this->_cacheTypeList->invalidate(\Magento\Framework\View\Element\AbstractBlock::CACHE_GROUP); + $this->cacheTypeList->invalidate(\Magento\Framework\View\Element\AbstractBlock::CACHE_GROUP); } + return parent::afterSave(); } } diff --git a/app/code/Magento/Tax/Model/Config/Notification.php b/app/code/Magento/Tax/Model/Config/Notification.php index 1c830caee477a..25b1cde5df60f 100644 --- a/app/code/Magento/Tax/Model/Config/Notification.php +++ b/app/code/Magento/Tax/Model/Config/Notification.php @@ -21,6 +21,7 @@ class Notification extends \Magento\Framework\App\Config\Value * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry * @param \Magento\Framework\App\Config\ScopeConfigInterface $config + * @param \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList * @param \Magento\Config\Model\ResourceModel\Config $resourceConfig * @param \Magento\Framework\Model\ModelResource\AbstractResource $resource * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection @@ -30,19 +31,20 @@ public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\App\Config\ScopeConfigInterface $config, + \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList, \Magento\Config\Model\ResourceModel\Config $resourceConfig, \Magento\Framework\Model\ModelResource\AbstractResource $resource = null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, array $data = [] ) { $this->resourceConfig = $resourceConfig; - parent::__construct($context, $registry, $config, $resource, $resourceCollection, $data); + parent::__construct($context, $registry, $config, $cacheTypeList, $resource, $resourceCollection, $data); } /** * Prepare and store cron settings after save * - * @return \Magento\Tax\Model\Config\Notification + * @return $this */ public function afterSave() { @@ -50,7 +52,7 @@ public function afterSave() $this->_resetNotificationFlag(\Magento\Tax\Model\Config::XML_PATH_TAX_NOTIFICATION_IGNORE_DISCOUNT); $this->_resetNotificationFlag(\Magento\Tax\Model\Config::XML_PATH_TAX_NOTIFICATION_IGNORE_PRICE_DISPLAY); } - return parent::afterSave($this); + return parent::afterSave(); } /** diff --git a/app/code/Magento/Tax/Model/Config/TaxClass.php b/app/code/Magento/Tax/Model/Config/TaxClass.php index 2d2503c8c3e56..2d47f9aae7bed 100644 --- a/app/code/Magento/Tax/Model/Config/TaxClass.php +++ b/app/code/Magento/Tax/Model/Config/TaxClass.php @@ -24,6 +24,7 @@ class TaxClass extends \Magento\Framework\App\Config\Value * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry * @param \Magento\Framework\App\Config\ScopeConfigInterface $config + * @param \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList * @param \Magento\Config\Model\ResourceModel\Config $resourceConfig * @param \Magento\Eav\Model\Entity\AttributeFactory $attributeFactory * @param \Magento\Framework\Model\ModelResource\AbstractResource $resource @@ -34,6 +35,7 @@ public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\App\Config\ScopeConfigInterface $config, + \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList, \Magento\Config\Model\ResourceModel\Config $resourceConfig, \Magento\Eav\Model\Entity\AttributeFactory $attributeFactory, \Magento\Framework\Model\ModelResource\AbstractResource $resource = null, @@ -42,15 +44,15 @@ public function __construct( ) { $this->resourceConfig = $resourceConfig; $this->attributeFactory = $attributeFactory; - parent::__construct($context, $registry, $config, $resource, $resourceCollection, $data); + parent::__construct($context, $registry, $config, $cacheTypeList, $resource, $resourceCollection, $data); } /** * Update the default product tax class * - * @return \Magento\Tax\Model\Config\TaxClass + * @return $this */ - protected function _afterSave() + public function afterSave() { $attributeCode = "tax_class_id"; @@ -62,6 +64,6 @@ protected function _afterSave() $attribute->setData("default_value", $this->getData('value')); $attribute->save(); - return parent::_afterSave($this); + return parent::afterSave(); } } diff --git a/app/code/Magento/Theme/Model/Design/Backend/Exceptions.php b/app/code/Magento/Theme/Model/Design/Backend/Exceptions.php index 948f64ef6a721..44a2e63bc7f95 100644 --- a/app/code/Magento/Theme/Model/Design/Backend/Exceptions.php +++ b/app/code/Magento/Theme/Model/Design/Backend/Exceptions.php @@ -22,6 +22,7 @@ class Exceptions extends ArraySerialized * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry * @param \Magento\Framework\App\Config\ScopeConfigInterface $config + * @param \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList * @param \Magento\Framework\View\DesignInterface $design * @param \Magento\Framework\Model\ModelResource\AbstractResource $resource * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection @@ -31,13 +32,14 @@ public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\App\Config\ScopeConfigInterface $config, + \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList, \Magento\Framework\View\DesignInterface $design, \Magento\Framework\Model\ModelResource\AbstractResource $resource = null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, array $data = [] ) { $this->_design = $design; - parent::__construct($context, $registry, $config, $resource, $resourceCollection, $data); + parent::__construct($context, $registry, $config, $cacheTypeList, $resource, $resourceCollection, $data); } /** diff --git a/app/code/Magento/Theme/Model/Design/Backend/Theme.php b/app/code/Magento/Theme/Model/Design/Backend/Theme.php index 5e85a547c3718..d77f694b4b474 100644 --- a/app/code/Magento/Theme/Model/Design/Backend/Theme.php +++ b/app/code/Magento/Theme/Model/Design/Backend/Theme.php @@ -16,28 +16,37 @@ class Theme extends Value */ protected $_design = null; + /** + * Path to config node with list of caches + * + * @var string + */ + const XML_PATH_INVALID_CACHES = 'design/invalid_caches'; + /** * Initialize dependencies * * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry * @param \Magento\Framework\App\Config\ScopeConfigInterface $config + * @param \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList * @param \Magento\Framework\View\DesignInterface $design - * @param \Magento\Framework\Model\ModelResource\AbstractResource $resource - * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection + * @param \Magento\Framework\Model\ModelResource\AbstractResource|null $resource + * @param \Magento\Framework\Data\Collection\AbstractDb|null $resourceCollection * @param array $data */ public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\App\Config\ScopeConfigInterface $config, + \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList, \Magento\Framework\View\DesignInterface $design, \Magento\Framework\Model\ModelResource\AbstractResource $resource = null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, array $data = [] ) { $this->_design = $design; - parent::__construct($context, $registry, $config, $resource, $resourceCollection, $data); + parent::__construct($context, $registry, $config, $cacheTypeList, $resource, $resourceCollection, $data); } /** @@ -53,4 +62,26 @@ public function beforeSave() } return parent::beforeSave(); } + + /** + * {@inheritdoc} + * + * {@inheritdoc}. In addition, it sets status 'invalidate' for blocks and other output caches + * + * @return $this + */ + public function afterSave() + { + $types = array_keys( + $this->_config->getValue( + self::XML_PATH_INVALID_CACHES, + \Magento\Store\Model\ScopeInterface::SCOPE_STORE + ) + ); + if ($this->isValueChanged()) { + $this->cacheTypeList->invalidate($types); + } + + return parent::afterSave(); + } } diff --git a/app/code/Magento/Theme/Test/Unit/Model/Design/Backend/ExceptionsTest.php b/app/code/Magento/Theme/Test/Unit/Model/Design/Backend/ExceptionsTest.php index 47a9acad4ee79..74760ac7a77a0 100644 --- a/app/code/Magento/Theme/Test/Unit/Model/Design/Backend/ExceptionsTest.php +++ b/app/code/Magento/Theme/Test/Unit/Model/Design/Backend/ExceptionsTest.php @@ -5,6 +5,7 @@ */ namespace Magento\Theme\Test\Unit\Model\Design\Backend; +use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; use Magento\Theme\Model\Design\Backend\Exceptions; use Magento\Framework\App\Area; @@ -18,60 +19,29 @@ class ExceptionsTest extends \PHPUnit_Framework_TestCase /** * @var \Magento\Framework\Model\Context|\PHPUnit_Framework_MockObject_MockObject */ - protected $context; - - /** - * @var \Magento\Framework\Registry|\PHPUnit_Framework_MockObject_MockObject - */ - protected $registry; - - /** - * @var \Magento\Framework\App\Config\ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject - */ - protected $config; + protected $contextMock; /** * @var \Magento\Framework\View\DesignInterface|\PHPUnit_Framework_MockObject_MockObject */ - protected $design; - - /** - * @var \Magento\Theme\Model\ResourceModel\Design|\PHPUnit_Framework_MockObject_MockObject - */ - protected $resource; - - /** - * @var \Magento\Theme\Model\ResourceModel\Design\Collection|\PHPUnit_Framework_MockObject_MockObject - */ - protected $resourceCollection; + protected $designMock; protected function setUp() { - $this->context = $this->getMockBuilder('Magento\Framework\Model\Context') - ->disableOriginalConstructor() - ->getMock(); - $this->registry = $this->getMockBuilder('Magento\Framework\Registry') - ->disableOriginalConstructor() - ->getMock(); - $this->config = $this->getMockBuilder('Magento\Framework\App\Config\ScopeConfigInterface')->getMock(); - $this->design = $this->getMockBuilder('Magento\Framework\View\DesignInterface')->getMock(); - $this->resource = $this->getMockBuilder('Magento\Theme\Model\ResourceModel\Design') - ->disableOriginalConstructor() - ->getMock(); - $this->resourceCollection = $this->getMockBuilder('Magento\Theme\Model\ResourceModel\Design\Collection') + $this->contextMock = $this->getMockBuilder('Magento\Framework\Model\Context') ->disableOriginalConstructor() ->getMock(); - $this->context->expects($this->once()) + $this->designMock = $this->getMockBuilder('Magento\Framework\View\DesignInterface')->getMock(); + $this->contextMock->expects($this->once()) ->method('getEventDispatcher') ->willReturn($this->getMockBuilder('Magento\Framework\Event\ManagerInterface')->getMock()); - $this->model = new Exceptions( - $this->context, - $this->registry, - $this->config, - $this->design, - $this->resource, - $this->resourceCollection + $this->model = (new ObjectManager($this))->getObject( + 'Magento\Theme\Model\Design\Backend\Exceptions', + [ + 'context' => $this->contextMock, + 'design' => $this->designMock, + ] ); } @@ -86,7 +56,7 @@ protected function setUp() public function testBeforeSave() { $value = ['__empty' => '', 'test' => ['search' => '1qwe', 'value' => '#val#', 'regexp' => '[a-zA-Z0-9]*']]; - $this->design->expects($this->once()) + $this->designMock->expects($this->once()) ->method('setDesignTheme') ->with('#val#', Area::AREA_FRONTEND); $this->model->setValue($value); diff --git a/app/code/Magento/Theme/Test/Unit/Model/Design/Backend/ThemeTest.php b/app/code/Magento/Theme/Test/Unit/Model/Design/Backend/ThemeTest.php index f6ac670502a89..14e25f826118e 100644 --- a/app/code/Magento/Theme/Test/Unit/Model/Design/Backend/ThemeTest.php +++ b/app/code/Magento/Theme/Test/Unit/Model/Design/Backend/ThemeTest.php @@ -7,6 +7,7 @@ namespace Magento\Theme\Test\Unit\Model\Design\Backend; use Magento\Framework\App\Area; +use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; use Magento\Theme\Model\Design\Backend\Theme; class ThemeTest extends \PHPUnit_Framework_TestCase @@ -19,60 +20,29 @@ class ThemeTest extends \PHPUnit_Framework_TestCase /** * @var \Magento\Framework\Model\Context|\PHPUnit_Framework_MockObject_MockObject */ - protected $context; - - /** - * @var \Magento\Framework\Registry|\PHPUnit_Framework_MockObject_MockObject - */ - protected $registry; - - /** - * @var \Magento\Framework\App\Config\ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject - */ - protected $config; + protected $contextMock; /** * @var \Magento\Framework\View\DesignInterface|\PHPUnit_Framework_MockObject_MockObject */ - protected $design; - - /** - * @var \Magento\Theme\Model\ResourceModel\Design|\PHPUnit_Framework_MockObject_MockObject - */ - protected $resource; - - /** - * @var \Magento\Theme\Model\ResourceModel\Design\Collection|\PHPUnit_Framework_MockObject_MockObject - */ - protected $resourceCollection; + protected $designMock; protected function setUp() { - $this->context = $this->getMockBuilder('Magento\Framework\Model\Context') - ->disableOriginalConstructor() - ->getMock(); - $this->registry = $this->getMockBuilder('Magento\Framework\Registry') - ->disableOriginalConstructor() - ->getMock(); - $this->config = $this->getMockBuilder('Magento\Framework\App\Config\ScopeConfigInterface')->getMock(); - $this->design = $this->getMockBuilder('Magento\Framework\View\DesignInterface')->getMock(); - $this->resource = $this->getMockBuilder('Magento\Theme\Model\ResourceModel\Design') - ->disableOriginalConstructor() - ->getMock(); - $this->resourceCollection = $this->getMockBuilder('Magento\Theme\Model\ResourceModel\Design\Collection') + $this->contextMock = $this->getMockBuilder('Magento\Framework\Model\Context') ->disableOriginalConstructor() ->getMock(); - $this->context->expects($this->once()) + $this->designMock = $this->getMockBuilder('Magento\Framework\View\DesignInterface')->getMock(); + $this->contextMock->expects($this->once()) ->method('getEventDispatcher') ->willReturn($this->getMockBuilder('Magento\Framework\Event\ManagerInterface')->getMock()); - $this->model = new Theme( - $this->context, - $this->registry, - $this->config, - $this->design, - $this->resource, - $this->resourceCollection + $this->model = (new ObjectManager($this))->getObject( + 'Magento\Theme\Model\Design\Backend\Theme', + [ + 'design' => $this->designMock, + 'context' => $this->contextMock, + ] ); } @@ -84,7 +54,7 @@ protected function setUp() */ public function testBeforeSave() { - $this->design->expects($this->once()) + $this->designMock->expects($this->once()) ->method('setDesignTheme') ->with('some_value', Area::AREA_FRONTEND); $this->model->setValue('some_value'); diff --git a/app/code/Magento/Theme/etc/config.xml b/app/code/Magento/Theme/etc/config.xml index 332043e56df87..4f25cd7e2abf9 100644 --- a/app/code/Magento/Theme/etc/config.xml +++ b/app/code/Magento/Theme/etc/config.xml @@ -8,6 +8,11 @@ + + + + + Magento Commerce Default Description diff --git a/lib/internal/Magento/Framework/App/Config/Value.php b/lib/internal/Magento/Framework/App/Config/Value.php index 1065c8f1f19ba..629b066aa35ad 100644 --- a/lib/internal/Magento/Framework/App/Config/Value.php +++ b/lib/internal/Magento/Framework/App/Config/Value.php @@ -42,10 +42,16 @@ class Value extends \Magento\Framework\Model\AbstractModel implements \Magento\F */ protected $_config; + /** + * @var \Magento\Framework\App\Cache\TypeListInterface + */ + protected $cacheTypeList; + /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry * @param \Magento\Framework\App\Config\ScopeConfigInterface $config + * @param \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList * @param \Magento\Framework\Model\ModelResource\AbstractResource $resource * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection * @param array $data @@ -54,12 +60,14 @@ public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\App\Config\ScopeConfigInterface $config, + \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList, \Magento\Framework\Model\ModelResource\AbstractResource $resource = null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, array $data = [] ) { $this->_config = $config; parent::__construct($context, $registry, $resource, $resourceCollection, $data); + $this->cacheTypeList = $cacheTypeList; } /** @@ -107,4 +115,20 @@ public function getFieldsetDataValue($key) $data = $this->_getData('fieldset_data'); return is_array($data) && isset($data[$key]) ? $data[$key] : null; } + + /** + * {@inheritdoc} + * + * {@inheritdoc}. In addition, it sets status 'invalidate' for config caches + * + * @return $this + */ + public function afterSave() + { + if ($this->isValueChanged()) { + $this->cacheTypeList->invalidate(\Magento\Framework\App\Cache\Type\Config::TYPE_IDENTIFIER); + } + + return parent::afterSave(); + } } From 323630196ea4fd0e7a856aa6be458783749c8ccc Mon Sep 17 00:00:00 2001 From: Joan He Date: Tue, 13 Oct 2015 15:12:16 -0500 Subject: [PATCH 02/26] MAGETWO-43857: [github] cache types don't properly invalidate all the time #1844 --- .../Model/Config/Backend/Currency/Allow.php | 2 +- .../Model/Config/Backend/Currency/Base.php | 2 +- .../Config/Model/Config/Backend/Translate.php | 26 ++++++++++++++----- .../Model/Config/Backend/ManagestockTest.php | 1 + .../Config/Backend/Image/AdapterTest.php | 1 + .../Model/Config/Backend/DomainTest.php | 1 + .../Model/Config/Backend/AllowedIpsTest.php | 1 + 7 files changed, 26 insertions(+), 8 deletions(-) diff --git a/app/code/Magento/Config/Model/Config/Backend/Currency/Allow.php b/app/code/Magento/Config/Model/Config/Backend/Currency/Allow.php index fecb071047272..61ed9ef526639 100644 --- a/app/code/Magento/Config/Model/Config/Backend/Currency/Allow.php +++ b/app/code/Magento/Config/Model/Config/Backend/Currency/Allow.php @@ -38,7 +38,7 @@ public function __construct( array $data = [] ) { $this->_localeCurrency = $localeCurrency; - parent::__construct($context, $registry, $config, $cacheTypeList, $resourceCollection, $resource, $data); + parent::__construct($context, $registry, $config, $cacheTypeList, $resource, $resourceCollection, $data); } /** diff --git a/app/code/Magento/Config/Model/Config/Backend/Currency/Base.php b/app/code/Magento/Config/Model/Config/Backend/Currency/Base.php index fe32b71564f34..abff700c12072 100644 --- a/app/code/Magento/Config/Model/Config/Backend/Currency/Base.php +++ b/app/code/Magento/Config/Model/Config/Backend/Currency/Base.php @@ -35,7 +35,7 @@ public function __construct( \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, array $data = [] ) { - parent::__construct($context, $registry, $config, $cacheTypeList, $resourceCollection, $resource, $data); + parent::__construct($context, $registry, $config, $cacheTypeList, $resource, $resourceCollection, $data); $this->currencyFactory = $currencyFactory; } diff --git a/app/code/Magento/Config/Model/Config/Backend/Translate.php b/app/code/Magento/Config/Model/Config/Backend/Translate.php index 665a7e68e1a13..6f6ae7071c74d 100644 --- a/app/code/Magento/Config/Model/Config/Backend/Translate.php +++ b/app/code/Magento/Config/Model/Config/Backend/Translate.php @@ -3,24 +3,38 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Rss\Model\System\Config\Backend; /** - * Cache cleaner backend model - * + * System config translate inline fields backend model */ -class Links extends \Magento\Framework\App\Config\Value +namespace Magento\Config\Model\Config\Backend; + +class Translate extends \Magento\Framework\App\Config\Value { /** - * Invalidate cache type, when value was changed + * Path to config node with list of caches + * + * @var string + */ + const XML_PATH_INVALID_CACHES = 'dev/translate_inline/invalid_caches'; + + /** + * Set status 'invalidate' for blocks and other output caches * * @return $this */ public function afterSave() { + $types = array_keys( + $this->_config->getValue( + self::XML_PATH_INVALID_CACHES, + \Magento\Store\Model\ScopeInterface::SCOPE_STORE + ) + ); if ($this->isValueChanged()) { - $this->cacheTypeList->invalidate(\Magento\Framework\View\Element\AbstractBlock::CACHE_GROUP); + $this->cacheTypeList->invalidate($types); } + return parent::afterSave(); } } diff --git a/dev/tests/integration/testsuite/Magento/CatalogInventory/Model/Config/Backend/ManagestockTest.php b/dev/tests/integration/testsuite/Magento/CatalogInventory/Model/Config/Backend/ManagestockTest.php index 07fcc69d89ca9..8f63143bddcd5 100644 --- a/dev/tests/integration/testsuite/Magento/CatalogInventory/Model/Config/Backend/ManagestockTest.php +++ b/dev/tests/integration/testsuite/Magento/CatalogInventory/Model/Config/Backend/ManagestockTest.php @@ -54,6 +54,7 @@ public function testSaveAndRebuildIndex($newStockValue, $callCount) Bootstrap::getObjectManager()->get('Magento\Framework\Model\Context'), Bootstrap::getObjectManager()->get('Magento\Framework\Registry'), Bootstrap::getObjectManager()->get('Magento\Framework\App\Config\ScopeConfigInterface'), + Bootstrap::getObjectManager()->get('Magento\Framework\App\Cache\TypeListInterface'), $stockManagement, Bootstrap::getObjectManager()->get('Magento\CatalogInventory\Model\Indexer\Stock\Processor'), Bootstrap::getObjectManager()->get('Magento\Config\Model\ResourceModel\Config') diff --git a/dev/tests/integration/testsuite/Magento/Config/Model/Config/Backend/Image/AdapterTest.php b/dev/tests/integration/testsuite/Magento/Config/Model/Config/Backend/Image/AdapterTest.php index fc7c961049df6..3bdc1817762a2 100644 --- a/dev/tests/integration/testsuite/Magento/Config/Model/Config/Backend/Image/AdapterTest.php +++ b/dev/tests/integration/testsuite/Magento/Config/Model/Config/Backend/Image/AdapterTest.php @@ -18,6 +18,7 @@ protected function setUp() $this->_model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( 'Magento\Config\Model\Config\Backend\Image\Adapter' ); + $this->_model->setPath('path'); } /** diff --git a/dev/tests/integration/testsuite/Magento/Cookie/Model/Config/Backend/DomainTest.php b/dev/tests/integration/testsuite/Magento/Cookie/Model/Config/Backend/DomainTest.php index 7f469f42e7bdb..5f24039ee0560 100644 --- a/dev/tests/integration/testsuite/Magento/Cookie/Model/Config/Backend/DomainTest.php +++ b/dev/tests/integration/testsuite/Magento/Cookie/Model/Config/Backend/DomainTest.php @@ -27,6 +27,7 @@ public function testBeforeSave($value, $exceptionMessage = null) 'Magento\Cookie\Model\Config\Backend\Domain' ); $domain->setValue($value); + $domain->setPath('path'); try { $domain->save(); if ($exceptionMessage) { diff --git a/dev/tests/integration/testsuite/Magento/Developer/Model/Config/Backend/AllowedIpsTest.php b/dev/tests/integration/testsuite/Magento/Developer/Model/Config/Backend/AllowedIpsTest.php index d34c64a96dc82..3b23c65d06b6c 100644 --- a/dev/tests/integration/testsuite/Magento/Developer/Model/Config/Backend/AllowedIpsTest.php +++ b/dev/tests/integration/testsuite/Magento/Developer/Model/Config/Backend/AllowedIpsTest.php @@ -22,6 +22,7 @@ public function testSaveWithEscapeHtml($value, $expected) 'Magento\Developer\Model\Config\Backend\AllowedIps' ); $model->setValue($value); + $model->setPath('path'); $model->beforeSave(); $model->save(); $this->assertEquals($expected, $model->getValue()); From d6189dd4c6bb4c149b2f9bdbd71d03ac58cfa1ef Mon Sep 17 00:00:00 2001 From: Joan He Date: Wed, 14 Oct 2015 15:40:25 -0500 Subject: [PATCH 03/26] MAGETWO-43857: [github] cache types don't properly invalidate all the time #1844 --- .../Unit/Model/Design/Backend/ThemeTest.php | 56 +++++++++++++++++++ .../App/Test/Unit/Config/ValueTest.php | 43 ++++++++++++-- 2 files changed, 94 insertions(+), 5 deletions(-) diff --git a/app/code/Magento/Theme/Test/Unit/Model/Design/Backend/ThemeTest.php b/app/code/Magento/Theme/Test/Unit/Model/Design/Backend/ThemeTest.php index 14e25f826118e..e83a4e4ca30eb 100644 --- a/app/code/Magento/Theme/Test/Unit/Model/Design/Backend/ThemeTest.php +++ b/app/code/Magento/Theme/Test/Unit/Model/Design/Backend/ThemeTest.php @@ -27,21 +27,37 @@ class ThemeTest extends \PHPUnit_Framework_TestCase */ protected $designMock; + /** + * @var \Magento\Framework\App\Cache\TypeListInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $cacheTypeListMock; + + /** + * @var \Magento\Framework\App\Config\ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $configMock; + protected function setUp() { $this->contextMock = $this->getMockBuilder('Magento\Framework\Model\Context') ->disableOriginalConstructor() ->getMock(); $this->designMock = $this->getMockBuilder('Magento\Framework\View\DesignInterface')->getMock(); + $this->cacheTypeListMock = $this->getMockBuilder('Magento\Framework\App\Cache\TypeListInterface') + ->disableOriginalConstructor() + ->getMock(); $this->contextMock->expects($this->once()) ->method('getEventDispatcher') ->willReturn($this->getMockBuilder('Magento\Framework\Event\ManagerInterface')->getMock()); + $this->configMock = $this->getMockBuilder('Magento\Framework\App\Config\ScopeConfigInterface')->getMock(); $this->model = (new ObjectManager($this))->getObject( 'Magento\Theme\Model\Design\Backend\Theme', [ 'design' => $this->designMock, 'context' => $this->contextMock, + 'cacheTypeList' => $this->cacheTypeListMock, + 'config' => $this->configMock, ] ); } @@ -60,4 +76,44 @@ public function testBeforeSave() $this->model->setValue('some_value'); $this->assertInstanceOf(get_class($this->model), $this->model->beforeSave()); } + + /** + * @param int $callNumber + * @param string $oldValue + * @dataProvider afterSaveDataProvider + */ + public function testAfterSave($callNumber, $oldValue) + { + $this->cacheTypeListMock->expects($this->exactly($callNumber)) + ->method('invalidate'); + $this->configMock->expects($this->any()) + ->method('getValue') + ->willReturnMap( + [ + [ + Theme::XML_PATH_INVALID_CACHES, + \Magento\Store\Model\ScopeInterface::SCOPE_STORE, + null, + ['block_html' => 1, 'layout' => 1, 'translate' => 1] + ], + [ + null, + \Magento\Framework\App\Config\ScopeConfigInterface::SCOPE_TYPE_DEFAULT, + null, + $oldValue + ], + + ] + ); + $this->model->setValue('some_value'); + $this->assertInstanceOf(get_class($this->model), $this->model->afterSave()); + } + + public function afterSaveDataProvider() + { + return [ + [0, 'some_value'], + [2, 'other_value'], + ]; + } } diff --git a/lib/internal/Magento/Framework/App/Test/Unit/Config/ValueTest.php b/lib/internal/Magento/Framework/App/Test/Unit/Config/ValueTest.php index db103705fefb6..175509af622a0 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/Config/ValueTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/Config/ValueTest.php @@ -15,27 +15,36 @@ class ValueTest extends \PHPUnit_Framework_TestCase /** * @var \Magento\Framework\Event\ManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ - protected $eventManager; + protected $eventManagerMock; /** * @var \Magento\Framework\App\Config\ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $configMock; + /** + * @var \Magento\Framework\App\Cache\TypeListInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $cacheTypeListMock; + /** * @return void */ protected function setUp() { $this->configMock = $this->getMock('Magento\Framework\App\Config\ScopeConfigInterface'); - $this->eventManager = $this->getMock('Magento\Framework\Event\ManagerInterface'); + $this->eventManagerMock = $this->getMock('Magento\Framework\Event\ManagerInterface'); + $this->cacheTypeListMock = $this->getMockBuilder('Magento\Framework\App\Cache\TypeListInterface') + ->disableOriginalConstructor() + ->getMock(); $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->model = $objectManager->getObject( 'Magento\Framework\App\Config\Value', [ 'config' => $this->configMock, - 'eventDispatcher' => $this->eventManager, + 'eventDispatcher' => $this->eventManagerMock, + 'cacheTypeList' => $this->cacheTypeListMock, ] ); } @@ -99,7 +108,7 @@ public function dataIsValueChanged() */ public function testAfterLoad() { - $this->eventManager->expects( + $this->eventManagerMock->expects( $this->at(0) )->method( 'dispatch' @@ -107,7 +116,7 @@ public function testAfterLoad() 'model_load_after', ['object' => $this->model] ); - $this->eventManager->expects( + $this->eventManagerMock->expects( $this->at(1) )->method( 'dispatch' @@ -158,4 +167,28 @@ public function dataProviderGetFieldsetDataValue() ], ]; } + + /** + * @param int $callNumber + * @param string $oldValue + * @dataProvider afterSaveDataProvider + */ + public function testAfterSave($callNumber, $oldValue) + { + $this->cacheTypeListMock->expects($this->exactly($callNumber)) + ->method('invalidate'); + $this->configMock->expects($this->any()) + ->method('getValue') + ->willReturn($oldValue); + $this->model->setValue('some_value'); + $this->assertInstanceOf(get_class($this->model), $this->model->afterSave()); + } + + public function afterSaveDataProvider() + { + return [ + [0, 'some_value'], + [1, 'other_value'], + ]; + } } From b165f7860b4765fd38dd8968a35fd34aaa2d5c20 Mon Sep 17 00:00:00 2001 From: Joan He Date: Fri, 16 Oct 2015 15:59:26 -0500 Subject: [PATCH 04/26] MAGETWO-43857: [github] cache types don't properly invalidate all the time #1844 --- lib/internal/Magento/Framework/App/Config/Value.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/internal/Magento/Framework/App/Config/Value.php b/lib/internal/Magento/Framework/App/Config/Value.php index 629b066aa35ad..32bb526b01516 100644 --- a/lib/internal/Magento/Framework/App/Config/Value.php +++ b/lib/internal/Magento/Framework/App/Config/Value.php @@ -66,8 +66,8 @@ public function __construct( array $data = [] ) { $this->_config = $config; - parent::__construct($context, $registry, $resource, $resourceCollection, $data); $this->cacheTypeList = $cacheTypeList; + parent::__construct($context, $registry, $resource, $resourceCollection, $data); } /** From 462893481c481f0138f23f0c250646ced07dd747 Mon Sep 17 00:00:00 2001 From: Joan He Date: Wed, 21 Oct 2015 16:30:58 -0500 Subject: [PATCH 05/26] MAGETWO-43857: [github] cache types don't properly invalidate all the time #1844 --- .../Theme/Model/Design/Backend/Theme.php | 14 ++---- .../Unit/Model/Design/Backend/ThemeTest.php | 47 +++++++++---------- app/code/Magento/Theme/etc/config.xml | 5 -- 3 files changed, 25 insertions(+), 41 deletions(-) diff --git a/app/code/Magento/Theme/Model/Design/Backend/Theme.php b/app/code/Magento/Theme/Model/Design/Backend/Theme.php index d77f694b4b474..4b5f23bcf34ab 100644 --- a/app/code/Magento/Theme/Model/Design/Backend/Theme.php +++ b/app/code/Magento/Theme/Model/Design/Backend/Theme.php @@ -66,22 +66,16 @@ public function beforeSave() /** * {@inheritdoc} * - * {@inheritdoc}. In addition, it sets status 'invalidate' for blocks and other output caches + * {@inheritdoc}. In addition, it cleans all * * @return $this */ public function afterSave() { - $types = array_keys( - $this->_config->getValue( - self::XML_PATH_INVALID_CACHES, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE - ) - ); + parent::afterSave(); if ($this->isValueChanged()) { - $this->cacheTypeList->invalidate($types); + $this->_cacheManager->clean(); } - - return parent::afterSave(); + return $this; } } diff --git a/app/code/Magento/Theme/Test/Unit/Model/Design/Backend/ThemeTest.php b/app/code/Magento/Theme/Test/Unit/Model/Design/Backend/ThemeTest.php index e83a4e4ca30eb..75530869fa56a 100644 --- a/app/code/Magento/Theme/Test/Unit/Model/Design/Backend/ThemeTest.php +++ b/app/code/Magento/Theme/Test/Unit/Model/Design/Backend/ThemeTest.php @@ -18,9 +18,9 @@ class ThemeTest extends \PHPUnit_Framework_TestCase protected $model; /** - * @var \Magento\Framework\Model\Context|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\Model\Context */ - protected $contextMock; + protected $context; /** * @var \Magento\Framework\View\DesignInterface|\PHPUnit_Framework_MockObject_MockObject @@ -32,6 +32,11 @@ class ThemeTest extends \PHPUnit_Framework_TestCase */ protected $cacheTypeListMock; + /** + * @var \Magento\Framework\App\CacheInterface | \PHPUnit_Framework_MockObject_MockObject + */ + protected $cacheManagerMock; + /** * @var \Magento\Framework\App\Config\ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject */ @@ -39,23 +44,27 @@ class ThemeTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->contextMock = $this->getMockBuilder('Magento\Framework\Model\Context') + $objectManager = new ObjectManager($this); + $this->cacheManagerMock = $this->getMockBuilder('Magento\Framework\App\CacheInterface') ->disableOriginalConstructor() ->getMock(); + $this->context = $objectManager->getObject( + 'Magento\Framework\Model\Context', + ['cacheManager' => $this->cacheManagerMock,] + ); + $this->designMock = $this->getMockBuilder('Magento\Framework\View\DesignInterface')->getMock(); $this->cacheTypeListMock = $this->getMockBuilder('Magento\Framework\App\Cache\TypeListInterface') ->disableOriginalConstructor() ->getMock(); - $this->contextMock->expects($this->once()) - ->method('getEventDispatcher') - ->willReturn($this->getMockBuilder('Magento\Framework\Event\ManagerInterface')->getMock()); $this->configMock = $this->getMockBuilder('Magento\Framework\App\Config\ScopeConfigInterface')->getMock(); - $this->model = (new ObjectManager($this))->getObject( + + $this->model = $objectManager->getObject( 'Magento\Theme\Model\Design\Backend\Theme', [ 'design' => $this->designMock, - 'context' => $this->contextMock, + 'context' => $this->context, 'cacheTypeList' => $this->cacheTypeListMock, 'config' => $this->configMock, ] @@ -86,25 +95,11 @@ public function testAfterSave($callNumber, $oldValue) { $this->cacheTypeListMock->expects($this->exactly($callNumber)) ->method('invalidate'); + $this->cacheManagerMock->expects($this->exactly($callNumber)) + ->method('clean'); $this->configMock->expects($this->any()) ->method('getValue') - ->willReturnMap( - [ - [ - Theme::XML_PATH_INVALID_CACHES, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, - null, - ['block_html' => 1, 'layout' => 1, 'translate' => 1] - ], - [ - null, - \Magento\Framework\App\Config\ScopeConfigInterface::SCOPE_TYPE_DEFAULT, - null, - $oldValue - ], - - ] - ); + ->willReturn($oldValue); $this->model->setValue('some_value'); $this->assertInstanceOf(get_class($this->model), $this->model->afterSave()); } @@ -113,7 +108,7 @@ public function afterSaveDataProvider() { return [ [0, 'some_value'], - [2, 'other_value'], + [1, 'other_value'], ]; } } diff --git a/app/code/Magento/Theme/etc/config.xml b/app/code/Magento/Theme/etc/config.xml index 4f25cd7e2abf9..332043e56df87 100644 --- a/app/code/Magento/Theme/etc/config.xml +++ b/app/code/Magento/Theme/etc/config.xml @@ -8,11 +8,6 @@ - - - - - Magento Commerce Default Description From 96878e4e3bf4f07d86be7587d8b28f04f683e0b6 Mon Sep 17 00:00:00 2001 From: Dale Sikkema Date: Wed, 21 Oct 2015 18:42:07 -0500 Subject: [PATCH 06/26] MAGETWO-44189: Does not work to switch the language in the admin area - remove locale switcher from backend --- .../Magento/Backend/Block/Page/Locale.php | 94 ------------------- .../Backend/view/adminhtml/layout/default.xml | 3 +- .../adminhtml/templates/page/locale.phtml | 31 ------ 3 files changed, 1 insertion(+), 127 deletions(-) delete mode 100644 app/code/Magento/Backend/Block/Page/Locale.php delete mode 100644 app/code/Magento/Backend/view/adminhtml/templates/page/locale.phtml diff --git a/app/code/Magento/Backend/Block/Page/Locale.php b/app/code/Magento/Backend/Block/Page/Locale.php deleted file mode 100644 index d6d279ac760f4..0000000000000 --- a/app/code/Magento/Backend/Block/Page/Locale.php +++ /dev/null @@ -1,94 +0,0 @@ -_localeLists = $localeLists; - $this->_localeResolver = $localeResolver; - $this->_urlHelper = $urlHelper; - parent::__construct($context, $data); - } - - /** - * Prepare URL for change locale - * - * @return string - */ - public function getChangeLocaleUrl() - { - return $this->getUrl('adminhtml/index/changeLocale'); - } - - /** - * Prepare current URL for referer - * - * @return string - */ - public function getUrlForReferer() - { - return ActionInterface::PARAM_NAME_URL_ENCODED . '/' . $this->_urlHelper->getEncodedUrl(); - } - - /** - * Retrieve locale select element - * - * @return string - */ - public function getLocaleSelect() - { - $html = $this->getLayout()->createBlock('Magento\Framework\View\Element\Html\Select') - ->setName('locale') - ->setId('footer_interface_locale') - ->setTitle(__('Interface Language')) - ->setClass('admin__control-select') - ->setValue($this->_localeResolver->getLocale()) - ->setOptions($this->_localeLists->getTranslatedOptionLocales()) - ->getHtml(); - - return $html; - } -} diff --git a/app/code/Magento/Backend/view/adminhtml/layout/default.xml b/app/code/Magento/Backend/view/adminhtml/layout/default.xml index f960316fcc929..56c7c5d553a80 100644 --- a/app/code/Magento/Backend/view/adminhtml/layout/default.xml +++ b/app/code/Magento/Backend/view/adminhtml/layout/default.xml @@ -53,8 +53,7 @@ - - + diff --git a/app/code/Magento/Backend/view/adminhtml/templates/page/locale.phtml b/app/code/Magento/Backend/view/adminhtml/templates/page/locale.phtml deleted file mode 100644 index 03347fbcbe695..0000000000000 --- a/app/code/Magento/Backend/view/adminhtml/templates/page/locale.phtml +++ /dev/null @@ -1,31 +0,0 @@ - -
- - getLocaleSelect(); ?> - -
From 3fe31b7cb6684a12f6c24d8b4d0396ca23bc4b59 Mon Sep 17 00:00:00 2001 From: Joan He Date: Thu, 22 Oct 2015 09:16:27 -0500 Subject: [PATCH 07/26] MAGETWO-43857: [github] cache types don't properly invalidate all the time #1844 --- .../Magento/Theme/Test/Unit/Model/Design/Backend/ThemeTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Theme/Test/Unit/Model/Design/Backend/ThemeTest.php b/app/code/Magento/Theme/Test/Unit/Model/Design/Backend/ThemeTest.php index 75530869fa56a..4082cac2232d8 100644 --- a/app/code/Magento/Theme/Test/Unit/Model/Design/Backend/ThemeTest.php +++ b/app/code/Magento/Theme/Test/Unit/Model/Design/Backend/ThemeTest.php @@ -50,7 +50,7 @@ protected function setUp() ->getMock(); $this->context = $objectManager->getObject( 'Magento\Framework\Model\Context', - ['cacheManager' => $this->cacheManagerMock,] + ['cacheManager' => $this->cacheManagerMock] ); $this->designMock = $this->getMockBuilder('Magento\Framework\View\DesignInterface')->getMock(); From f6f26912fa2b83e4a3ef955d6fbe8b162cc92eae Mon Sep 17 00:00:00 2001 From: Joan He Date: Thu, 22 Oct 2015 14:02:22 -0500 Subject: [PATCH 08/26] MAGETWO-43857: [github] cache types don't properly invalidate all the time #1844 --- app/code/Magento/Theme/Model/Design/Backend/Theme.php | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/app/code/Magento/Theme/Model/Design/Backend/Theme.php b/app/code/Magento/Theme/Model/Design/Backend/Theme.php index cafa2703fd427..d58e9b382427a 100644 --- a/app/code/Magento/Theme/Model/Design/Backend/Theme.php +++ b/app/code/Magento/Theme/Model/Design/Backend/Theme.php @@ -16,13 +16,6 @@ class Theme extends Value */ protected $_design = null; - /** - * Path to config node with list of caches - * - * @var string - */ - const XML_PATH_INVALID_CACHES = 'design/invalid_caches'; - /** * Initialize dependencies * @@ -66,7 +59,7 @@ public function beforeSave() /** * {@inheritdoc} * - * {@inheritdoc}. In addition, it cleans all + * {@inheritdoc}. In addition, it cleans all Magento cache * * @return $this */ From 8d1842a0ea6afef4f5db923a06b96f5bf4d9be41 Mon Sep 17 00:00:00 2001 From: Dale Sikkema Date: Thu, 22 Oct 2015 21:30:12 -0500 Subject: [PATCH 09/26] MAGETWO-44470: clear generated files in CLI framework - clear var/generation when command is for compilation --- .../Magento/Framework/Console/Cli.php | 27 ++++++-- .../Console/Command/DiCompileCommand.php | 6 +- .../Command/DiCompileMultiTenantCommand.php | 5 +- .../Setup/Console/CompilerPreparation.php | 64 +++++++++++++++++++ 4 files changed, 95 insertions(+), 7 deletions(-) create mode 100644 setup/src/Magento/Setup/Console/CompilerPreparation.php diff --git a/lib/internal/Magento/Framework/Console/Cli.php b/lib/internal/Magento/Framework/Console/Cli.php index 786a658b7e9ac..8fb5e79d6722a 100644 --- a/lib/internal/Magento/Framework/Console/Cli.php +++ b/lib/internal/Magento/Framework/Console/Cli.php @@ -22,6 +22,27 @@ class Cli extends SymfonyApplication */ const INPUT_KEY_BOOTSTRAP = 'bootstrap'; + /** @var \Zend\ServiceManager\ServiceManager */ + private $serviceManager; + + /** + * @param string $name The name of the application + * @param string $version The version of the application + */ + public function __construct($name = 'UNKNOWN', $version = 'UNKNOWN') + { + $this->serviceManager = \Zend\Mvc\Application::init(require BP . '/setup/config/application.config.php') + ->getServiceManager(); + /** + * Temporary workaround until the compiler is able to clear the generation directory. (MAGETWO-44493) + */ + if (class_exists('Magento\Setup\Console\CompilerPreparation')) { + (new \Magento\Setup\Console\CompilerPreparation($this->serviceManager))->handleCompilerEnvironment(); + } + + parent::__construct($name, $version); + } + /** * {@inheritdoc} */ @@ -45,14 +66,12 @@ protected function getApplicationCommands() $params[Bootstrap::PARAM_REQUIRE_MAINTENANCE] = null; $bootstrap = Bootstrap::create(BP, $params); $objectManager = $bootstrap->getObjectManager(); - $serviceManager = \Zend\Mvc\Application::init(require BP . '/setup/config/application.config.php') - ->getServiceManager(); /** @var \Magento\Setup\Model\ObjectManagerProvider $omProvider */ - $omProvider = $serviceManager->get('Magento\Setup\Model\ObjectManagerProvider'); + $omProvider = $this->serviceManager->get('Magento\Setup\Model\ObjectManagerProvider'); $omProvider->setObjectManager($objectManager); if (class_exists('Magento\Setup\Console\CommandList')) { - $setupCommandList = new \Magento\Setup\Console\CommandList($serviceManager); + $setupCommandList = new \Magento\Setup\Console\CommandList($this->serviceManager); $setupCommands = $setupCommandList->getCommands(); } diff --git a/setup/src/Magento/Setup/Console/Command/DiCompileCommand.php b/setup/src/Magento/Setup/Console/Command/DiCompileCommand.php index b404778db1629..8138a0db280a5 100644 --- a/setup/src/Magento/Setup/Console/Command/DiCompileCommand.php +++ b/setup/src/Magento/Setup/Console/Command/DiCompileCommand.php @@ -28,6 +28,9 @@ */ class DiCompileCommand extends Command { + /** Command name */ + const NAME = 'setup:di:compile'; + /** @var DeploymentConfig */ private $deploymentConfig; @@ -89,7 +92,7 @@ public function __construct( */ protected function configure() { - $this->setName('setup:di:compile') + $this->setName(self::NAME) ->setDescription( 'Generates DI configuration and all non-existing interceptors and factories' ); @@ -172,7 +175,6 @@ protected function execute(InputInterface $input, OutputInterface $output) $this->cleanupFilesystem( [ DirectoryList::CACHE, - DirectoryList::GENERATION, DirectoryList::DI, ] ); diff --git a/setup/src/Magento/Setup/Console/Command/DiCompileMultiTenantCommand.php b/setup/src/Magento/Setup/Console/Command/DiCompileMultiTenantCommand.php index 33f8f763ede31..ea56ed13dbd4d 100644 --- a/setup/src/Magento/Setup/Console/Command/DiCompileMultiTenantCommand.php +++ b/setup/src/Magento/Setup/Console/Command/DiCompileMultiTenantCommand.php @@ -56,6 +56,9 @@ class DiCompileMultiTenantCommand extends AbstractSetupCommand const SERIALIZER_VALUE_IGBINARY = 'igbinary'; /**#@- */ + /** Command name */ + const NAME = 'setup:di:compile-multi-tenant'; + /** * Object Manager * @@ -155,7 +158,7 @@ protected function configure() 'Allows to exclude Paths from compilation (default is #[\\\\/]m1[\\\\/]#i)' ), ]; - $this->setName('setup:di:compile-multi-tenant') + $this->setName(self::NAME) ->setDescription( 'Generates all non-existing proxies and factories, and pre-compile class definitions, ' . 'inheritance information and plugin definitions' diff --git a/setup/src/Magento/Setup/Console/CompilerPreparation.php b/setup/src/Magento/Setup/Console/CompilerPreparation.php new file mode 100644 index 0000000000000..457b4f23b3750 --- /dev/null +++ b/setup/src/Magento/Setup/Console/CompilerPreparation.php @@ -0,0 +1,64 @@ +serviceManager = $serviceManager; + } + + /** + * Determine whether a CLI command is for compilation, and if so, clear the directory + * + * @throws \Magento\Framework\Exception\FileSystemException + */ + public function handleCompilerEnvironment() + { + $input = new ArgvInput(); + $compilationCommands = [DiCompileCommand::NAME, DiCompileMultiTenantCommand::NAME]; + $cmdName = $input->getFirstArgument(); + $isHelpOption = $input->hasParameterOption('--help') || $input->hasParameterOption('-h'); + + if (!in_array($cmdName, $compilationCommands) || $isHelpOption) { + return; + } + + $generationDir = ($cmdName === DiCompileMultiTenantCommand::NAME) + ? $input->getParameterOption(DiCompileMultiTenantCommand::INPUT_KEY_GENERATION) + : null; + + if (!$generationDir) { + $mageInitParams = $this->serviceManager->get(InitParamListener::BOOTSTRAP_PARAM); + $mageDirs = isset($mageInitParams[Bootstrap::INIT_PARAM_FILESYSTEM_DIR_PATHS]) + ? $mageInitParams[Bootstrap::INIT_PARAM_FILESYSTEM_DIR_PATHS] + : []; + $generationDir = (new DirectoryList(BP, $mageDirs))->getPath(DirectoryList::GENERATION); + } + + $filesystemDriver = new File(); + if ($filesystemDriver->isExists($generationDir)) { + $filesystemDriver->deleteDirectory($generationDir); + } + } +} From 38bcb3c079b709ccce980ee69b3c9ac49ecb3df9 Mon Sep 17 00:00:00 2001 From: Dale Sikkema Date: Thu, 22 Oct 2015 23:03:18 -0500 Subject: [PATCH 10/26] MAGETWO-44470: clear generated files in CLI framework - add unit test coverage - refactor CompilerPreparation --- .../Magento/Framework/Console/Cli.php | 5 +- .../Setup/Console/CompilerPreparation.php | 30 ++- .../Console/Command/DiCompileCommandTest.php | 1 + .../DiCompileMultiTenantCommandTest.php | 21 ++ .../Unit/Console/CompilerPreparationTest.php | 181 ++++++++++++++++++ 5 files changed, 228 insertions(+), 10 deletions(-) create mode 100644 setup/src/Magento/Setup/Test/Unit/Console/CompilerPreparationTest.php diff --git a/lib/internal/Magento/Framework/Console/Cli.php b/lib/internal/Magento/Framework/Console/Cli.php index 8fb5e79d6722a..56b792bf85b8f 100644 --- a/lib/internal/Magento/Framework/Console/Cli.php +++ b/lib/internal/Magento/Framework/Console/Cli.php @@ -6,9 +6,11 @@ namespace Magento\Framework\Console; +use Magento\Framework\Filesystem\Driver\File; use Symfony\Component\Console\Application as SymfonyApplication; use Magento\Framework\App\Bootstrap; use Magento\Framework\Shell\ComplexParameter; +use Symfony\Component\Console\Input\ArgvInput; /** * Magento2 CLI Application. This is the hood for all command line tools supported by Magento. @@ -37,7 +39,8 @@ public function __construct($name = 'UNKNOWN', $version = 'UNKNOWN') * Temporary workaround until the compiler is able to clear the generation directory. (MAGETWO-44493) */ if (class_exists('Magento\Setup\Console\CompilerPreparation')) { - (new \Magento\Setup\Console\CompilerPreparation($this->serviceManager))->handleCompilerEnvironment(); + (new \Magento\Setup\Console\CompilerPreparation($this->serviceManager, new ArgvInput(), new File())) + ->handleCompilerEnvironment(); } parent::__construct($name, $version); diff --git a/setup/src/Magento/Setup/Console/CompilerPreparation.php b/setup/src/Magento/Setup/Console/CompilerPreparation.php index 457b4f23b3750..23e796bfcec88 100644 --- a/setup/src/Magento/Setup/Console/CompilerPreparation.php +++ b/setup/src/Magento/Setup/Console/CompilerPreparation.php @@ -20,12 +20,26 @@ class CompilerPreparation /** @var \Zend\ServiceManager\ServiceManager */ private $serviceManager; + /** @var ArgvInput */ + private $input; + + /** @var File */ + private $filesystemDriver; + /** * @param \Zend\ServiceManager\ServiceManager $serviceManager + * @param ArgvInput $input + * @param File $filesystemDriver */ - public function __construct(\Zend\ServiceManager\ServiceManager $serviceManager) + public function __construct( + \Zend\ServiceManager\ServiceManager $serviceManager, + \Symfony\Component\Console\Input\ArgvInput $input, + \Magento\Framework\Filesystem\Driver\File $filesystemDriver + ) { - $this->serviceManager = $serviceManager; + $this->serviceManager = $serviceManager; + $this->input = $input; + $this->filesystemDriver = $filesystemDriver; } /** @@ -35,17 +49,16 @@ public function __construct(\Zend\ServiceManager\ServiceManager $serviceManager) */ public function handleCompilerEnvironment() { - $input = new ArgvInput(); $compilationCommands = [DiCompileCommand::NAME, DiCompileMultiTenantCommand::NAME]; - $cmdName = $input->getFirstArgument(); - $isHelpOption = $input->hasParameterOption('--help') || $input->hasParameterOption('-h'); + $cmdName = $this->input->getFirstArgument(); + $isHelpOption = $this->input->hasParameterOption('--help') || $this->input->hasParameterOption('-h'); if (!in_array($cmdName, $compilationCommands) || $isHelpOption) { return; } $generationDir = ($cmdName === DiCompileMultiTenantCommand::NAME) - ? $input->getParameterOption(DiCompileMultiTenantCommand::INPUT_KEY_GENERATION) + ? $this->input->getParameterOption(DiCompileMultiTenantCommand::INPUT_KEY_GENERATION) : null; if (!$generationDir) { @@ -56,9 +69,8 @@ public function handleCompilerEnvironment() $generationDir = (new DirectoryList(BP, $mageDirs))->getPath(DirectoryList::GENERATION); } - $filesystemDriver = new File(); - if ($filesystemDriver->isExists($generationDir)) { - $filesystemDriver->deleteDirectory($generationDir); + if ($this->filesystemDriver->isExists($generationDir)) { + $this->filesystemDriver->deleteDirectory($generationDir); } } } diff --git a/setup/src/Magento/Setup/Test/Unit/Console/Command/DiCompileCommandTest.php b/setup/src/Magento/Setup/Test/Unit/Console/Command/DiCompileCommandTest.php index 4230d3a67d882..303e4a801428d 100644 --- a/setup/src/Magento/Setup/Test/Unit/Console/Command/DiCompileCommandTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Console/Command/DiCompileCommandTest.php @@ -149,5 +149,6 @@ public function testExecute() 'Generated code and dependency injection configuration successfully.', explode(PHP_EOL, $tester->getDisplay()) ); + $this->assertSame(DiCompileCommand::NAME, $this->command->getName()); } } diff --git a/setup/src/Magento/Setup/Test/Unit/Console/Command/DiCompileMultiTenantCommandTest.php b/setup/src/Magento/Setup/Test/Unit/Console/Command/DiCompileMultiTenantCommandTest.php index 45edf5578c833..c8581808c6660 100644 --- a/setup/src/Magento/Setup/Test/Unit/Console/Command/DiCompileMultiTenantCommandTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Console/Command/DiCompileMultiTenantCommandTest.php @@ -6,11 +6,22 @@ namespace Magento\Setup\Test\Unit\Console\Command; use Magento\Framework\Component\ComponentRegistrar; +use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; use Magento\Setup\Console\Command\DiCompileMultiTenantCommand; use Symfony\Component\Console\Tester\CommandTester; class DiCompileMultiTenantCommandTest extends \PHPUnit_Framework_TestCase { + /** @var \Magento\Setup\Console\Command\DiCompileMultiTenantCommand */ + private $model; + + public function setUp() + { + $this->model = (new ObjectManager($this))->getObject( + '\Magento\Setup\Console\Command\DiCompileMultiTenantCommand' + ); + } + /** * @dataProvider validateDataProvider * @param array $option @@ -83,4 +94,14 @@ public function validateDataProvider() ], ]; } + + public function testConfigure() + { + $methodUnderTest = new \ReflectionMethod($this->model, 'configure'); + $methodUnderTest->setAccessible(true); + $methodUnderTest->invoke($this->model); + $this->assertSame(DiCompileMultiTenantCommand::NAME, $this->model->getName()); + $this->assertNotEmpty($this->model->getDescription()); + $this->assertCount(6, $this->model->getDefinition()->getOptions()); + } } diff --git a/setup/src/Magento/Setup/Test/Unit/Console/CompilerPreparationTest.php b/setup/src/Magento/Setup/Test/Unit/Console/CompilerPreparationTest.php new file mode 100644 index 0000000000000..cc46c653e8bc8 --- /dev/null +++ b/setup/src/Magento/Setup/Test/Unit/Console/CompilerPreparationTest.php @@ -0,0 +1,181 @@ +serviceManagerMock = $this->getMockBuilder('\Zend\ServiceManager\ServiceManager') + ->disableOriginalConstructor() + ->getMock(); + $this->inputMock = $this->getMockBuilder('\Symfony\Component\Console\Input\ArgvInput') + ->disableOriginalConstructor() + ->getMock(); + $this->filesystemDriverMock = $this->getMockBuilder('\Magento\Framework\Filesystem\Driver\File') + ->disableOriginalConstructor() + ->getMock(); + $this->model = (new ObjectManager($this))->getObject( + '\Magento\Setup\Console\CompilerPreparation', + [ + 'serviceManager' => $this->serviceManagerMock, + 'input' => $this->inputMock, + 'filesystemDriver' => $this->filesystemDriverMock + ] + ); + } + + /** + * @dataProvider commandNameDataProvider + * @param $commandName + * @param $isCompileCommand + * @param $isHelpOption + * @param bool|null $dirExists + */ + public function testClearGenerationDirWhenNeeded($commandName, $isCompileCommand, $isHelpOption, $dirExists = false) + { + $this->inputMock->expects($this->once())->method('getFirstArgument')->willReturn($commandName); + $this->inputMock->expects($this->atLeastOnce()) + ->method('hasParameterOption') + ->with( + $this->logicalOr('--help', '-h') + )->willReturn($isHelpOption); + if ($isCompileCommand && !$isHelpOption) { + $this->filesystemDriverMock->expects($this->once()) + ->method('isExists') + ->willReturn($dirExists); + $this->filesystemDriverMock->expects($this->exactly((int)$dirExists))->method('deleteDirectory'); + } else { + $this->filesystemDriverMock->expects($this->never())->method('isExists'); + $this->filesystemDriverMock->expects($this->never())->method('deleteDirectory'); + } + $this->model->handleCompilerEnvironment(); + } + + public function commandNameDataProvider() + { + return [ + 'ST compiler, directory exists' => [ + 'commandName' => DiCompileCommand::NAME, + 'isCompileCommand' => true, + 'isHelpOption' => false, + 'dirExists' => true + ], + 'ST compiler, directory does not exist' => [ + 'commandName' => DiCompileCommand::NAME, + 'isCompileCommand' => true, + 'isHelpOption' => false, + 'dirExists' => false + ], + 'ST compiler, help option' => [ + 'commandName' => DiCompileCommand::NAME, + 'isCompileCommand' => true, + 'isHelpOption' => true, + 'dirExists' => false + ], + 'MT compiler, directory exists' => [ + 'commandName' => DiCompileMultiTenantCommand::NAME, + 'isCompileCommand' => true, + 'isHelpOption' => false, + 'dirExists' => true + ], + 'MT compiler, directory does not exist' => [ + 'commandName' => DiCompileMultiTenantCommand::NAME, + 'isCompileCommand' => true, + 'isHelpOption' => false, + 'dirExists' => false + ], + 'MT compiler, help option' => [ + 'commandName' => DiCompileMultiTenantCommand::NAME, + 'isCompileCommand' => true, + 'isHelpOption' => true, + 'dirExists' => true + ], + 'Other command' => [ + 'commandName' => 'not:a:compiler', + 'isCompileCommand' => false, + 'isHelpOption' => false, + ] + ]; + } + + public function testGenerationDirectoryFromInitParams() + { + $customGenerationDirectory = '/custom/generated/code/directory'; + $mageInitParams = ['MAGE_DIRS' => ['generation' => ['path' => $customGenerationDirectory]]]; + + $this->inputMock->expects($this->once()) + ->method('getFirstArgument') + ->willReturn(DiCompileMultiTenantCommand::NAME); + + // Filesystem mock + $this->filesystemDriverMock->expects($this->once())->method('isExists')->willReturn(true); + $this->filesystemDriverMock->expects($this->once()) + ->method('deleteDirectory') + ->with($customGenerationDirectory); + + $this->serviceManagerMock->expects($this->once()) + ->method('get') + ->with(InitParamListener::BOOTSTRAP_PARAM) + ->willReturn($mageInitParams); + $this->model->handleCompilerEnvironment(); + } + + /** + * @dataProvider compilerCommandDataProvider + */ + public function testGenerationDirectoryFromCliOption($commandName) + { + $customGenerationDirectory = '/custom/generated/code/directory'; + $useCliOption = $commandName === DiCompileMultiTenantCommand::NAME; + + $this->inputMock->expects($this->once()) + ->method('getFirstArgument') + ->willReturn($commandName); + $this->inputMock->expects($this->exactly((int)$useCliOption)) + ->method('getParameterOption') + ->with(DiCompileMultiTenantCommand::INPUT_KEY_GENERATION) + ->willReturn($customGenerationDirectory); + // Filesystem mock + $directoryArgConstraint = $useCliOption + ? $this->equalTo($customGenerationDirectory) + : $this->logicalNot($this->equalTo($customGenerationDirectory)); + $this->filesystemDriverMock->expects($this->once())->method('isExists')->willReturn(true); + $this->filesystemDriverMock->expects($this->once()) + ->method('deleteDirectory') + ->with($directoryArgConstraint); + + $this->model->handleCompilerEnvironment(); + } + + public function compilerCommandDataProvider() + { + return [ + [DiCompileCommand::NAME], + [DiCompileMultiTenantCommand::NAME] + ]; + } +} From b3061c49fc5ed0a2f305d80e1d430783ea80d97a Mon Sep 17 00:00:00 2001 From: Joan He Date: Fri, 23 Oct 2015 14:51:28 -0500 Subject: [PATCH 11/26] MAGETWO-41954: Eliminate code generatio in production mode --- .../Framework/Interception/Config/Config.php | 2 +- .../Test/Unit/Config/ConfigTest.php | 13 +- .../Console/Command/DiCompileCommand.php | 14 ++- .../Operation/ApplicationCodeGenerator.php | 35 +++++- .../Di/App/Task/Operation/Interception.php | 7 +- .../Di/App/Task/Operation/ProxyGenerator.php | 75 ++++++++++++ .../Task/Operation/RepositoryGenerator.php | 10 +- .../Module/Di/App/Task/OperationFactory.php | 8 +- .../Console/Command/DiCompileCommandTest.php | 2 +- .../App/Task/ApplicationCodeGeneratorTest.php | 111 ++++++++++++++++++ .../Module/Di/App/Task/ProxyGeneratorTest.php | 94 +++++++++++++++ 11 files changed, 358 insertions(+), 13 deletions(-) create mode 100644 setup/src/Magento/Setup/Module/Di/App/Task/Operation/ProxyGenerator.php create mode 100644 setup/src/Magento/Setup/Test/Unit/Module/Di/App/Task/ApplicationCodeGeneratorTest.php create mode 100644 setup/src/Magento/Setup/Test/Unit/Module/Di/App/Task/ProxyGeneratorTest.php diff --git a/lib/internal/Magento/Framework/Interception/Config/Config.php b/lib/internal/Magento/Framework/Interception/Config/Config.php index 7c9ede12daf5c..43be5547c46a4 100644 --- a/lib/internal/Magento/Framework/Interception/Config/Config.php +++ b/lib/internal/Magento/Framework/Interception/Config/Config.php @@ -63,7 +63,7 @@ class Config implements \Magento\Framework\Interception\ConfigInterface * * @var array */ - protected $_serviceClassTypes = ['Proxy', 'Interceptor']; + protected $_serviceClassTypes = ['Interceptor']; /** * @var \Magento\Framework\Config\ScopeListInterface diff --git a/lib/internal/Magento/Framework/Interception/Test/Unit/Config/ConfigTest.php b/lib/internal/Magento/Framework/Interception/Test/Unit/Config/ConfigTest.php index 6c12758905634..b2bcba673e2a7 100644 --- a/lib/internal/Magento/Framework/Interception/Test/Unit/Config/ConfigTest.php +++ b/lib/internal/Magento/Framework/Interception/Test/Unit/Config/ConfigTest.php @@ -102,6 +102,10 @@ public function testHasPluginsWhenDataIsNotCached($expectedResult, $type, $entit 'Magento\Framework\Interception\Test\Unit\Custom\Module\Model\ItemContainer\Enhanced', 'Magento\Framework\Interception\Test\Unit\Custom\Module\Model\ItemContainer\Enhanced', ], + [ + 'Magento\Framework\Interception\Test\Unit\Custom\Module\Model\ItemContainer\Proxy', + 'Magento\Framework\Interception\Test\Unit\Custom\Module\Model\ItemContainer\Proxy', + ], [ 'Magento\Framework\Interception\Test\Unit\Custom\Module\Model\ItemProxy', 'Magento\Framework\Interception\Test\Unit\Custom\Module\Model\ItemProxy', @@ -151,6 +155,7 @@ public function testHasPluginsWhenDataIsCached($expectedResult, $type) 'Magento\Framework\Interception\Test\Unit\Custom\Module\Model\Item' => true, 'Magento\Framework\Interception\Test\Unit\Custom\Module\Model\Item\Enhanced' => true, 'Magento\Framework\Interception\Test\Unit\Custom\Module\Model\ItemContainer\Enhanced' => true, + 'Magento\Framework\Interception\Test\Unit\Custom\Module\Model\ItemContainer\Proxy' => true, 'Magento\Framework\Interception\Test\Unit\Custom\Module\Model\ItemProxy' => false, 'virtual_custom_item' => true, ]; @@ -195,7 +200,13 @@ public function hasPluginsDataProvider() [ // the following model has only inherited plugins true, - 'Magento\Framework\Interception\Test\Unit\Custom\Module\Model\ItemContainer\Enhanced', + 'Magento\Framework\Interception\Test\Unit\Custom\Module\Model\ItemContainer\Proxy', + ['Magento\Framework\Interception\Test\Unit\Custom\Module\Model\ItemContainer'], + ], + [ + // the following model has only inherited plugins + true, + 'Magento\Framework\Interception\Test\Unit\Custom\Module\Model\ItemContainer\Proxy', ['Magento\Framework\Interception\Test\Unit\Custom\Module\Model\ItemContainer'], ], [ diff --git a/setup/src/Magento/Setup/Console/Command/DiCompileCommand.php b/setup/src/Magento/Setup/Console/Command/DiCompileCommand.php index 8138a0db280a5..8540a636d63f6 100644 --- a/setup/src/Magento/Setup/Console/Command/DiCompileCommand.php +++ b/setup/src/Magento/Setup/Console/Command/DiCompileCommand.php @@ -294,6 +294,10 @@ private function getOperationsConfiguration( array $dataAttributesIncludePattern ) { $operations = [ + OperationFactory::PROXY_GENERATOR => [ + 'paths' => $compiledPathsList['application'], + 'filePatterns' => ['di' => '/\/etc\/([a-zA-Z_]*\/di|di)\.xml$/'] + ], OperationFactory::REPOSITORY_GENERATOR => [ 'paths' => $compiledPathsList['application'], 'filePatterns' => ['di' => '/\/etc\/([a-zA-Z_]*\/di|di)\.xml$/'] @@ -303,9 +307,13 @@ private function getOperationsConfiguration( 'filePatterns' => $dataAttributesIncludePattern ], OperationFactory::APPLICATION_CODE_GENERATOR => [ - $compiledPathsList['application'], - $compiledPathsList['library'], - $compiledPathsList['generated_helpers'], + 'paths' => [ + $compiledPathsList['application'], + $compiledPathsList['library'], + $compiledPathsList['generated_helpers'], + ], + 'filePatterns' => ['php' => '/\.php$/'], + 'excludePatterns' => ['/\/Test\//'] ], OperationFactory::INTERCEPTION => [ 'intercepted_paths' => [ diff --git a/setup/src/Magento/Setup/Module/Di/App/Task/Operation/ApplicationCodeGenerator.php b/setup/src/Magento/Setup/Module/Di/App/Task/Operation/ApplicationCodeGenerator.php index 3b412d15cc14a..21254457ddf66 100644 --- a/setup/src/Magento/Setup/Module/Di/App/Task/Operation/ApplicationCodeGenerator.php +++ b/setup/src/Magento/Setup/Module/Di/App/Task/Operation/ApplicationCodeGenerator.php @@ -5,8 +5,12 @@ */ namespace Magento\Setup\Module\Di\App\Task\Operation; +use Magento\Framework\App\Bootstrap; +use Magento\Framework\Exception\FileSystemException; use Magento\Setup\Module\Di\App\Task\OperationInterface; use Magento\Setup\Module\Di\Code\Reader\ClassesScanner; +use Magento\Setup\Module\Di\Code\Scanner\DirectoryScanner; +use Magento\Setup\Module\Di\Code\Scanner\PhpScanner; class ApplicationCodeGenerator implements OperationInterface { @@ -20,16 +24,30 @@ class ApplicationCodeGenerator implements OperationInterface */ private $classesScanner; + /** + * @var PhpScanner + */ + private $phpScanner; + + /** + * @var DirectoryScanner + */ + private $directoryScanner; + /** * @param ClassesScanner $classesScanner * @param array $data */ public function __construct( ClassesScanner $classesScanner, + PhpScanner $phpScanner, + DirectoryScanner $directoryScanner, $data = [] ) { $this->data = $data; $this->classesScanner = $classesScanner; + $this->phpScanner = $phpScanner; + $this->directoryScanner = $directoryScanner; } /** @@ -37,16 +55,27 @@ public function __construct( */ public function doOperation() { - if (empty($this->data)) { + if (array_diff(array_keys($this->data), ['filePatterns', 'paths', 'excludePatterns']) + !== array_diff(['filePatterns', 'paths', 'excludePatterns'], array_keys($this->data))) { return; } - foreach ($this->data as $paths) { + foreach ($this->data['paths'] as $paths) { if (!is_array($paths)) { $paths = (array)$paths; } + $files = []; foreach ($paths as $path) { - $this->classesScanner->getList($path); + try { + $this->classesScanner->getList($path); + $files = array_merge_recursive($files, $this->directoryScanner->scan($path, $this->data['filePatterns'], $this->data['excludePatterns'])); + } catch(FileSystemException $e) { + // skip + } + } + $entities = $this->phpScanner->collectEntities($files['php']); + foreach ($entities as $entityName) { + class_exists($entityName); } } } diff --git a/setup/src/Magento/Setup/Module/Di/App/Task/Operation/Interception.php b/setup/src/Magento/Setup/Module/Di/App/Task/Operation/Interception.php index 0c48cd4f519ec..269e65bb48cf3 100644 --- a/setup/src/Magento/Setup/Module/Di/App/Task/Operation/Interception.php +++ b/setup/src/Magento/Setup/Module/Di/App/Task/Operation/Interception.php @@ -5,6 +5,7 @@ */ namespace Magento\Setup\Module\Di\App\Task\Operation; +use Magento\Framework\Exception\FileSystemException; use Magento\Setup\Module\Di\App\Task\OperationInterface; use Magento\Setup\Module\Di\Code\Generator\InterceptionConfigurationBuilder; use Magento\Framework\Interception\Code\Generator\Interceptor; @@ -80,7 +81,11 @@ public function doOperation() $paths = (array)$paths; } foreach ($paths as $path) { - $classesList = array_merge($classesList, $this->classesScanner->getList($path)); + try { + $classesList = array_merge($classesList, $this->classesScanner->getList($path)); + } catch(FileSystemException $e) { + // skip + } } } diff --git a/setup/src/Magento/Setup/Module/Di/App/Task/Operation/ProxyGenerator.php b/setup/src/Magento/Setup/Module/Di/App/Task/Operation/ProxyGenerator.php new file mode 100644 index 0000000000000..38751954c9eef --- /dev/null +++ b/setup/src/Magento/Setup/Module/Di/App/Task/Operation/ProxyGenerator.php @@ -0,0 +1,75 @@ +directoryScanner = $directoryScanner; + $this->proxyScanner = $proxyScanner; + $this->data = $data; + } + + /** + * Processes operation task + * + * @return void + */ + public function doOperation() + { + if (array_diff(array_keys($this->data), ['filePatterns', 'paths']) + !== array_diff(['filePatterns', 'paths'], array_keys($this->data))) { + return; + } + + $files = []; + foreach ($this->data['paths'] as $path) { + $files = array_merge_recursive($files, $this->directoryScanner->scan($path, $this->data['filePatterns'])); + } + $proxies = $this->proxyScanner->collectEntities($files['di']); + foreach ($proxies as $entityName) { + class_exists($entityName); + } + } + + /** + * Returns operation name + * + * @return string + */ + public function getName() + { + return 'Proxies code generation'; + } +} diff --git a/setup/src/Magento/Setup/Module/Di/App/Task/Operation/RepositoryGenerator.php b/setup/src/Magento/Setup/Module/Di/App/Task/Operation/RepositoryGenerator.php index cf3c779a3f776..d72b4c932a740 100644 --- a/setup/src/Magento/Setup/Module/Di/App/Task/Operation/RepositoryGenerator.php +++ b/setup/src/Magento/Setup/Module/Di/App/Task/Operation/RepositoryGenerator.php @@ -6,6 +6,7 @@ namespace Magento\Setup\Module\Di\App\Task\Operation; +use Magento\Framework\Exception\FileSystemException; use Magento\Setup\Module\Di\App\Task\OperationInterface; use Magento\Setup\Module\Di\Code\Scanner; use Magento\Setup\Module\Di\Code\Reader\ClassesScanner; @@ -62,9 +63,14 @@ public function doOperation() return; } - foreach ($this->data['paths'] as $path) { - $this->classesScanner->getList($path); + try { + foreach ($this->data['paths'] as $path) { + $this->classesScanner->getList($path); + } + } catch(FileSystemException $e) { + // skip } + $this->repositoryScanner->setUseAutoload(false); $files = []; foreach ($this->data['paths'] as $path) { diff --git a/setup/src/Magento/Setup/Module/Di/App/Task/OperationFactory.php b/setup/src/Magento/Setup/Module/Di/App/Task/OperationFactory.php index dd6bfa1f5ff3a..cb5c930f6e40a 100644 --- a/setup/src/Magento/Setup/Module/Di/App/Task/OperationFactory.php +++ b/setup/src/Magento/Setup/Module/Di/App/Task/OperationFactory.php @@ -32,6 +32,11 @@ class OperationFactory */ const REPOSITORY_GENERATOR = 'repository_generator'; + /** + * Proxy generator + */ + const PROXY_GENERATOR = 'proxy_generator'; + /** * Service data attributes generator */ @@ -53,7 +58,8 @@ class OperationFactory self::APPLICATION_CODE_GENERATOR => 'Magento\Setup\Module\Di\App\Task\Operation\ApplicationCodeGenerator', self::INTERCEPTION => 'Magento\Setup\Module\Di\App\Task\Operation\Interception', self::INTERCEPTION_CACHE => 'Magento\Setup\Module\Di\App\Task\Operation\InterceptionCache', - self::REPOSITORY_GENERATOR => 'Magento\Setup\Module\Di\App\Task\Operation\RepositoryGenerator' + self::REPOSITORY_GENERATOR => 'Magento\Setup\Module\Di\App\Task\Operation\RepositoryGenerator', + self::PROXY_GENERATOR => 'Magento\Setup\Module\Di\App\Task\Operation\ProxyGenerator', ]; /** diff --git a/setup/src/Magento/Setup/Test/Unit/Console/Command/DiCompileCommandTest.php b/setup/src/Magento/Setup/Test/Unit/Console/Command/DiCompileCommandTest.php index 303e4a801428d..2cbf5cc3f8e3b 100644 --- a/setup/src/Magento/Setup/Test/Unit/Console/Command/DiCompileCommandTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Console/Command/DiCompileCommandTest.php @@ -141,7 +141,7 @@ public function testExecute() ->method('create') ->with('Symfony\Component\Console\Helper\ProgressBar') ->willReturn($progressBar); - $this->manager->expects($this->exactly(6))->method('addOperation'); + $this->manager->expects($this->exactly(7))->method('addOperation'); $this->manager->expects($this->once())->method('process'); $tester = new CommandTester($this->command); $tester->execute([]); diff --git a/setup/src/Magento/Setup/Test/Unit/Module/Di/App/Task/ApplicationCodeGeneratorTest.php b/setup/src/Magento/Setup/Test/Unit/Module/Di/App/Task/ApplicationCodeGeneratorTest.php new file mode 100644 index 0000000000000..0a988bb3a5141 --- /dev/null +++ b/setup/src/Magento/Setup/Test/Unit/Module/Di/App/Task/ApplicationCodeGeneratorTest.php @@ -0,0 +1,111 @@ +directoryScannerMock = $this->getMockBuilder('Magento\Setup\Module\Di\Code\Scanner\DirectoryScanner') + ->disableOriginalConstructor() + ->getMock(); + $this->phpScannerMock = $this->getMockBuilder('Magento\Setup\Module\Di\Code\Scanner\PhpScanner') + ->disableOriginalConstructor() + ->getMock(); + $this->classesScannerMock = $this->getMockBuilder('Magento\Setup\Module\Di\Code\Reader\ClassesScanner') + ->disableOriginalConstructor() + ->getMock(); + } + + /** + * @param array $data + * + * @dataProvider doOperationWrongDataDataProvider + */ + public function testDoOperationWrongData($data) + { + $model = new ApplicationCodeGenerator( + $this->classesScannerMock, + $this->phpScannerMock, + $this->directoryScannerMock, + $data + ); + + $this->classesScannerMock->expects($this->never()) + ->method('getList'); + $this->directoryScannerMock->expects($this->never()) + ->method('scan'); + $this->phpScannerMock->expects($this->never()) + ->method('collectEntities'); + + $this->assertEmpty($model->doOperation()); + } + + /** + * @return array + */ + public function doOperationWrongDataDataProvider() + { + return [ + [[]], + [['filePatterns' => ['php' => '*.php']]], + [['path' => 'path']], + ]; + } + + public function testDoOperation() + { + $data = [ + 'paths' => ['path/to/app'], + 'filePatterns' => ['php' => '.php'], + 'excludePatterns' => ['/\/Test\//'] + ]; + $files = ['php' => []]; + $model = new ApplicationCodeGenerator( + $this->classesScannerMock, + $this->phpScannerMock, + $this->directoryScannerMock, + $data + ); + + $this->classesScannerMock->expects($this->once()) + ->method('getList') + ->with($data['paths'][0]); + $this->directoryScannerMock->expects($this->once()) + ->method('scan') + ->with( + $data['paths'][0], + $data['filePatterns'], + $data['excludePatterns'] + )->willReturn($files); + $this->phpScannerMock->expects($this->once()) + ->method('collectEntities') + ->with($files['php']) + ->willReturn([]); + + $this->assertEmpty($model->doOperation()); + } +} diff --git a/setup/src/Magento/Setup/Test/Unit/Module/Di/App/Task/ProxyGeneratorTest.php b/setup/src/Magento/Setup/Test/Unit/Module/Di/App/Task/ProxyGeneratorTest.php new file mode 100644 index 0000000000000..9b78e237db30e --- /dev/null +++ b/setup/src/Magento/Setup/Test/Unit/Module/Di/App/Task/ProxyGeneratorTest.php @@ -0,0 +1,94 @@ +directoryScannerMock = $this->getMockBuilder('Magento\Setup\Module\Di\Code\Scanner\DirectoryScanner') + ->disableOriginalConstructor() + ->getMock(); + $this->proxyScannerMock = $this->getMockBuilder('Magento\Setup\Module\Di\Code\Scanner\XmlScanner') + ->disableOriginalConstructor() + ->getMock(); + } + + /** + * @param array $data + * + * @dataProvider doOperationWrongDataDataProvider + */ + public function testDoOperationWrongData($data) + { + $model = new ProxyGenerator( + $this->directoryScannerMock, + $this->proxyScannerMock, + $data + ); + + $this->directoryScannerMock->expects($this->never()) + ->method('scan'); + $this->proxyScannerMock->expects($this->never()) + ->method('collectEntities'); + + $this->assertEmpty($model->doOperation()); + } + + /** + * @return array + */ + public function doOperationWrongDataDataProvider() + { + return [ + [[]], + [['filePatterns' => ['php' => '*.php']]], + [['path' => 'path']], + ]; + } + + public function testDoOperation() + { + $data = [ + 'paths' => ['path/to/app'], + 'filePatterns' => ['di' => 'di.xml'], + ]; + $files = ['di' => []]; + $model = new ProxyGenerator( + $this->directoryScannerMock, + $this->proxyScannerMock, + $data + ); + + $this->directoryScannerMock->expects($this->once()) + ->method('scan') + ->with( + $data['paths'][0], + $data['filePatterns'] + )->willReturn($files); + $this->proxyScannerMock->expects($this->once()) + ->method('collectEntities') + ->with($files['di']) + ->willReturn([]); + + $this->assertEmpty($model->doOperation()); + } +} From c068c8e5a86f9ee75b48decbc458a7cd1965482b Mon Sep 17 00:00:00 2001 From: Dale Sikkema Date: Fri, 23 Oct 2015 14:54:38 -0500 Subject: [PATCH 12/26] MAGETWO-44189: Does not work to switch the language in the admin area - apply new style to the legal section --- .../Backend/view/adminhtml/layout/default.xml | 20 +++++++++++-------- .../adminhtml/templates/page/copyright.phtml | 6 ++---- .../web/css/source/module/_footer.less | 10 +++------- 3 files changed, 17 insertions(+), 19 deletions(-) diff --git a/app/code/Magento/Backend/view/adminhtml/layout/default.xml b/app/code/Magento/Backend/view/adminhtml/layout/default.xml index 56c7c5d553a80..216934514bcc5 100644 --- a/app/code/Magento/Backend/view/adminhtml/layout/default.xml +++ b/app/code/Magento/Backend/view/adminhtml/layout/default.xml @@ -53,14 +53,18 @@
- - - - - - https://github.com/magento/magento2/issues - - + + + + + + + + + https://github.com/magento/magento2/issues + + + diff --git a/app/code/Magento/Backend/view/adminhtml/templates/page/copyright.phtml b/app/code/Magento/Backend/view/adminhtml/templates/page/copyright.phtml index 5612ab2066179..41781c9d1287f 100644 --- a/app/code/Magento/Backend/view/adminhtml/templates/page/copyright.phtml +++ b/app/code/Magento/Backend/view/adminhtml/templates/page/copyright.phtml @@ -7,7 +7,5 @@ // @codingStandardsIgnoreFile ?> - + + diff --git a/app/design/adminhtml/Magento/backend/Magento_Backend/web/css/source/module/_footer.less b/app/design/adminhtml/Magento/backend/Magento_Backend/web/css/source/module/_footer.less index 65e24732ac4fa..7752b6d2feda2 100644 --- a/app/design/adminhtml/Magento/backend/Magento_Backend/web/css/source/module/_footer.less +++ b/app/design/adminhtml/Magento/backend/Magento_Backend/web/css/source/module/_footer.less @@ -53,6 +53,7 @@ // Copyright .copyright { + text-align: left; margin-bottom: -.2rem; position: relative; .link-copyright { @@ -85,15 +86,10 @@ .footer-legal { padding-top: 1rem; - text-align: right; } -// Locale switcher -.locale-switcher { - .label { - display: block; - margin-bottom: 1rem; - } +.footer-legal-system { + text-align: right; } // From bbb9f6c131afcc3ae2f84f6e774b36df3acf7bd4 Mon Sep 17 00:00:00 2001 From: Joan He Date: Fri, 23 Oct 2015 15:10:56 -0500 Subject: [PATCH 13/26] MAGETWO-43857: [github] cache types don't properly invalidate all the time #1844 --- .../Theme/Model/Design/Backend/Theme.php | 1 + .../Unit/Model/Design/Backend/ThemeTest.php | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/Theme/Model/Design/Backend/Theme.php b/app/code/Magento/Theme/Model/Design/Backend/Theme.php index d58e9b382427a..108e82528a064 100644 --- a/app/code/Magento/Theme/Model/Design/Backend/Theme.php +++ b/app/code/Magento/Theme/Model/Design/Backend/Theme.php @@ -68,6 +68,7 @@ public function afterSave() parent::afterSave(); if ($this->isValueChanged()) { $this->_cacheManager->clean(); + $this->_eventManager->dispatch('adminhtml_cache_flush_system'); } return $this; } diff --git a/app/code/Magento/Theme/Test/Unit/Model/Design/Backend/ThemeTest.php b/app/code/Magento/Theme/Test/Unit/Model/Design/Backend/ThemeTest.php index 4082cac2232d8..e394482d74865 100644 --- a/app/code/Magento/Theme/Test/Unit/Model/Design/Backend/ThemeTest.php +++ b/app/code/Magento/Theme/Test/Unit/Model/Design/Backend/ThemeTest.php @@ -32,6 +32,11 @@ class ThemeTest extends \PHPUnit_Framework_TestCase */ protected $cacheTypeListMock; + /** + * @var \Magento\Framework\Event\ManagerInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $eventManagerMock; + /** * @var \Magento\Framework\App\CacheInterface | \PHPUnit_Framework_MockObject_MockObject */ @@ -48,9 +53,15 @@ protected function setUp() $this->cacheManagerMock = $this->getMockBuilder('Magento\Framework\App\CacheInterface') ->disableOriginalConstructor() ->getMock(); + $this->eventManagerMock = $this->getMockBuilder('Magento\Framework\Event\ManagerInterface') + ->disableOriginalConstructor() + ->getMock(); $this->context = $objectManager->getObject( 'Magento\Framework\Model\Context', - ['cacheManager' => $this->cacheManagerMock] + [ + 'cacheManager' => $this->cacheManagerMock, + 'eventDispatcher' => $this->eventManagerMock, + ] ); $this->designMock = $this->getMockBuilder('Magento\Framework\View\DesignInterface')->getMock(); @@ -100,6 +111,11 @@ public function testAfterSave($callNumber, $oldValue) $this->configMock->expects($this->any()) ->method('getValue') ->willReturn($oldValue); + if ($callNumber) { + $this->eventManagerMock->expects($this->at(3)) + ->method('dispatch') + ->with('adminhtml_cache_flush_system'); + } $this->model->setValue('some_value'); $this->assertInstanceOf(get_class($this->model), $this->model->afterSave()); } From 7d65c78f9f013208a2369c6801f840e91e4fe5ae Mon Sep 17 00:00:00 2001 From: Joan He Date: Fri, 23 Oct 2015 15:57:11 -0500 Subject: [PATCH 14/26] MAGETWO-41954: Eliminate code generatio in production mode --- .../Module/Di/App/Task/Operation/Interception.php | 7 +------ .../Di/App/Task/Operation/RepositoryGenerator.php | 10 ++-------- 2 files changed, 3 insertions(+), 14 deletions(-) diff --git a/setup/src/Magento/Setup/Module/Di/App/Task/Operation/Interception.php b/setup/src/Magento/Setup/Module/Di/App/Task/Operation/Interception.php index 269e65bb48cf3..0c48cd4f519ec 100644 --- a/setup/src/Magento/Setup/Module/Di/App/Task/Operation/Interception.php +++ b/setup/src/Magento/Setup/Module/Di/App/Task/Operation/Interception.php @@ -5,7 +5,6 @@ */ namespace Magento\Setup\Module\Di\App\Task\Operation; -use Magento\Framework\Exception\FileSystemException; use Magento\Setup\Module\Di\App\Task\OperationInterface; use Magento\Setup\Module\Di\Code\Generator\InterceptionConfigurationBuilder; use Magento\Framework\Interception\Code\Generator\Interceptor; @@ -81,11 +80,7 @@ public function doOperation() $paths = (array)$paths; } foreach ($paths as $path) { - try { - $classesList = array_merge($classesList, $this->classesScanner->getList($path)); - } catch(FileSystemException $e) { - // skip - } + $classesList = array_merge($classesList, $this->classesScanner->getList($path)); } } diff --git a/setup/src/Magento/Setup/Module/Di/App/Task/Operation/RepositoryGenerator.php b/setup/src/Magento/Setup/Module/Di/App/Task/Operation/RepositoryGenerator.php index d72b4c932a740..cf3c779a3f776 100644 --- a/setup/src/Magento/Setup/Module/Di/App/Task/Operation/RepositoryGenerator.php +++ b/setup/src/Magento/Setup/Module/Di/App/Task/Operation/RepositoryGenerator.php @@ -6,7 +6,6 @@ namespace Magento\Setup\Module\Di\App\Task\Operation; -use Magento\Framework\Exception\FileSystemException; use Magento\Setup\Module\Di\App\Task\OperationInterface; use Magento\Setup\Module\Di\Code\Scanner; use Magento\Setup\Module\Di\Code\Reader\ClassesScanner; @@ -63,14 +62,9 @@ public function doOperation() return; } - try { - foreach ($this->data['paths'] as $path) { - $this->classesScanner->getList($path); - } - } catch(FileSystemException $e) { - // skip + foreach ($this->data['paths'] as $path) { + $this->classesScanner->getList($path); } - $this->repositoryScanner->setUseAutoload(false); $files = []; foreach ($this->data['paths'] as $path) { From 369a00bc82b31a9618bdbb394c58c0f19aa83f01 Mon Sep 17 00:00:00 2001 From: Joan He Date: Fri, 23 Oct 2015 16:00:09 -0500 Subject: [PATCH 15/26] MAGETWO-41954: Eliminate code generatio in production mode --- .../Di/App/Task/Operation/ApplicationCodeGenerator.php | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/setup/src/Magento/Setup/Module/Di/App/Task/Operation/ApplicationCodeGenerator.php b/setup/src/Magento/Setup/Module/Di/App/Task/Operation/ApplicationCodeGenerator.php index 21254457ddf66..dfaf5b9957090 100644 --- a/setup/src/Magento/Setup/Module/Di/App/Task/Operation/ApplicationCodeGenerator.php +++ b/setup/src/Magento/Setup/Module/Di/App/Task/Operation/ApplicationCodeGenerator.php @@ -66,12 +66,8 @@ public function doOperation() } $files = []; foreach ($paths as $path) { - try { - $this->classesScanner->getList($path); - $files = array_merge_recursive($files, $this->directoryScanner->scan($path, $this->data['filePatterns'], $this->data['excludePatterns'])); - } catch(FileSystemException $e) { - // skip - } + $this->classesScanner->getList($path); + $files = array_merge_recursive($files, $this->directoryScanner->scan($path, $this->data['filePatterns'], $this->data['excludePatterns'])); } $entities = $this->phpScanner->collectEntities($files['php']); foreach ($entities as $entityName) { From 4fda69b73e93e2f044fda1483a68a2a39e0a6f19 Mon Sep 17 00:00:00 2001 From: Joan He Date: Fri, 23 Oct 2015 22:59:34 -0500 Subject: [PATCH 16/26] MAGETWO-41954: Eliminate code generatio in production mode --- .../Module/Di/App/Task/Operation/ApplicationCodeGenerator.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/setup/src/Magento/Setup/Module/Di/App/Task/Operation/ApplicationCodeGenerator.php b/setup/src/Magento/Setup/Module/Di/App/Task/Operation/ApplicationCodeGenerator.php index dfaf5b9957090..b18f413fb68b0 100644 --- a/setup/src/Magento/Setup/Module/Di/App/Task/Operation/ApplicationCodeGenerator.php +++ b/setup/src/Magento/Setup/Module/Di/App/Task/Operation/ApplicationCodeGenerator.php @@ -36,6 +36,8 @@ class ApplicationCodeGenerator implements OperationInterface /** * @param ClassesScanner $classesScanner + * @param PhpScanner $phpScanner + * @param DirectoryScanner $directoryScanner * @param array $data */ public function __construct( From 6aac527a0e1354fc0d5648ebbab3f6ff881e400f Mon Sep 17 00:00:00 2001 From: Dale Sikkema Date: Sun, 25 Oct 2015 14:47:40 -0500 Subject: [PATCH 17/26] MAGETWO-44470: clear generated files in CLI framework - fixed CR comments --- setup/src/Magento/Setup/Console/CompilerPreparation.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup/src/Magento/Setup/Console/CompilerPreparation.php b/setup/src/Magento/Setup/Console/CompilerPreparation.php index 23e796bfcec88..adfefd3db07c0 100644 --- a/setup/src/Magento/Setup/Console/CompilerPreparation.php +++ b/setup/src/Magento/Setup/Console/CompilerPreparation.php @@ -35,8 +35,7 @@ public function __construct( \Zend\ServiceManager\ServiceManager $serviceManager, \Symfony\Component\Console\Input\ArgvInput $input, \Magento\Framework\Filesystem\Driver\File $filesystemDriver - ) - { + ) { $this->serviceManager = $serviceManager; $this->input = $input; $this->filesystemDriver = $filesystemDriver; @@ -46,6 +45,7 @@ public function __construct( * Determine whether a CLI command is for compilation, and if so, clear the directory * * @throws \Magento\Framework\Exception\FileSystemException + * @return void */ public function handleCompilerEnvironment() { From 5d7d0bc7d16e53d2258b9f147405c8f94e6c4e56 Mon Sep 17 00:00:00 2001 From: Joan He Date: Mon, 26 Oct 2015 00:02:31 -0500 Subject: [PATCH 18/26] MAGETWO-41954: Eliminate code generatio in production mode --- .../Magento/Setup/Console/Command/DiCompileCommand.php | 6 ++++-- .../Di/App/Task/Operation/ApplicationCodeGenerator.php | 5 ++++- .../Module/Di/App/Task/Operation/ProxyGenerator.php | 9 ++++++--- .../Module/Di/App/Task/Operation/RepositoryGenerator.php | 9 ++++++--- .../Test/Unit/Module/Di/App/Task/ProxyGeneratorTest.php | 1 + .../Unit/Module/Di/App/Task/RepositoryGeneratorTest.php | 3 ++- 6 files changed, 23 insertions(+), 10 deletions(-) diff --git a/setup/src/Magento/Setup/Console/Command/DiCompileCommand.php b/setup/src/Magento/Setup/Console/Command/DiCompileCommand.php index 8540a636d63f6..9b2b2f5977de5 100644 --- a/setup/src/Magento/Setup/Console/Command/DiCompileCommand.php +++ b/setup/src/Magento/Setup/Console/Command/DiCompileCommand.php @@ -296,11 +296,13 @@ private function getOperationsConfiguration( $operations = [ OperationFactory::PROXY_GENERATOR => [ 'paths' => $compiledPathsList['application'], - 'filePatterns' => ['di' => '/\/etc\/([a-zA-Z_]*\/di|di)\.xml$/'] + 'filePatterns' => ['di' => '/\/etc\/([a-zA-Z_]*\/di|di)\.xml$/'], + 'excludePatterns' => ['/\/Test\//'] ], OperationFactory::REPOSITORY_GENERATOR => [ 'paths' => $compiledPathsList['application'], - 'filePatterns' => ['di' => '/\/etc\/([a-zA-Z_]*\/di|di)\.xml$/'] + 'filePatterns' => ['di' => '/\/etc\/([a-zA-Z_]*\/di|di)\.xml$/'], + 'excludePatterns' => ['/\/Test\//'] ], OperationFactory::DATA_ATTRIBUTES_GENERATOR => [ 'paths' => $compiledPathsList['application'], diff --git a/setup/src/Magento/Setup/Module/Di/App/Task/Operation/ApplicationCodeGenerator.php b/setup/src/Magento/Setup/Module/Di/App/Task/Operation/ApplicationCodeGenerator.php index b18f413fb68b0..bd66d8e122360 100644 --- a/setup/src/Magento/Setup/Module/Di/App/Task/Operation/ApplicationCodeGenerator.php +++ b/setup/src/Magento/Setup/Module/Di/App/Task/Operation/ApplicationCodeGenerator.php @@ -69,7 +69,10 @@ public function doOperation() $files = []; foreach ($paths as $path) { $this->classesScanner->getList($path); - $files = array_merge_recursive($files, $this->directoryScanner->scan($path, $this->data['filePatterns'], $this->data['excludePatterns'])); + $files = array_merge_recursive( + $files, + $this->directoryScanner->scan($path, $this->data['filePatterns'], $this->data['excludePatterns']) + ); } $entities = $this->phpScanner->collectEntities($files['php']); foreach ($entities as $entityName) { diff --git a/setup/src/Magento/Setup/Module/Di/App/Task/Operation/ProxyGenerator.php b/setup/src/Magento/Setup/Module/Di/App/Task/Operation/ProxyGenerator.php index 38751954c9eef..ebfec0635b8bb 100644 --- a/setup/src/Magento/Setup/Module/Di/App/Task/Operation/ProxyGenerator.php +++ b/setup/src/Magento/Setup/Module/Di/App/Task/Operation/ProxyGenerator.php @@ -48,14 +48,17 @@ public function __construct( */ public function doOperation() { - if (array_diff(array_keys($this->data), ['filePatterns', 'paths']) - !== array_diff(['filePatterns', 'paths'], array_keys($this->data))) { + if (array_diff(array_keys($this->data), ['filePatterns', 'paths', 'excludePatterns']) + !== array_diff(['filePatterns', 'paths', 'excludePatterns'], array_keys($this->data))) { return; } $files = []; foreach ($this->data['paths'] as $path) { - $files = array_merge_recursive($files, $this->directoryScanner->scan($path, $this->data['filePatterns'])); + $files = array_merge_recursive( + $files, + $this->directoryScanner->scan($path, $this->data['filePatterns'], $this->data['excludePatterns']) + ); } $proxies = $this->proxyScanner->collectEntities($files['di']); foreach ($proxies as $entityName) { diff --git a/setup/src/Magento/Setup/Module/Di/App/Task/Operation/RepositoryGenerator.php b/setup/src/Magento/Setup/Module/Di/App/Task/Operation/RepositoryGenerator.php index cf3c779a3f776..60d1159661528 100644 --- a/setup/src/Magento/Setup/Module/Di/App/Task/Operation/RepositoryGenerator.php +++ b/setup/src/Magento/Setup/Module/Di/App/Task/Operation/RepositoryGenerator.php @@ -57,8 +57,8 @@ public function __construct( */ public function doOperation() { - if (array_diff(array_keys($this->data), ['filePatterns', 'paths']) - !== array_diff(['filePatterns', 'paths'], array_keys($this->data))) { + if (array_diff(array_keys($this->data), ['filePatterns', 'paths', 'excludePatterns']) + !== array_diff(['filePatterns', 'paths', 'excludePatterns'], array_keys($this->data))) { return; } @@ -68,7 +68,10 @@ public function doOperation() $this->repositoryScanner->setUseAutoload(false); $files = []; foreach ($this->data['paths'] as $path) { - $files = array_merge_recursive($files, $this->directoryScanner->scan($path, $this->data['filePatterns'])); + $files = array_merge_recursive( + $files, + $this->directoryScanner->scan($path, $this->data['filePatterns'], $this->data['excludePatterns']) + ); } $repositories = $this->repositoryScanner->collectEntities($files['di']); foreach ($repositories as $entityName) { diff --git a/setup/src/Magento/Setup/Test/Unit/Module/Di/App/Task/ProxyGeneratorTest.php b/setup/src/Magento/Setup/Test/Unit/Module/Di/App/Task/ProxyGeneratorTest.php index 9b78e237db30e..c721973f615ef 100644 --- a/setup/src/Magento/Setup/Test/Unit/Module/Di/App/Task/ProxyGeneratorTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Module/Di/App/Task/ProxyGeneratorTest.php @@ -70,6 +70,7 @@ public function testDoOperation() $data = [ 'paths' => ['path/to/app'], 'filePatterns' => ['di' => 'di.xml'], + 'excludePatterns' => ['/\/Test\//'], ]; $files = ['di' => []]; $model = new ProxyGenerator( diff --git a/setup/src/Magento/Setup/Test/Unit/Module/Di/App/Task/RepositoryGeneratorTest.php b/setup/src/Magento/Setup/Test/Unit/Module/Di/App/Task/RepositoryGeneratorTest.php index 8b49d60df518b..626ccfbe71346 100644 --- a/setup/src/Magento/Setup/Test/Unit/Module/Di/App/Task/RepositoryGeneratorTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Module/Di/App/Task/RepositoryGeneratorTest.php @@ -16,7 +16,7 @@ class RepositoryGeneratorTest extends \PHPUnit_Framework_TestCase * @var Scanner\DirectoryScanner | \PHPUnit_Framework_MockObject_MockObject */ private $directoryScannerMock; - + /** * @var Scanner\RepositoryScanner | \PHPUnit_Framework_MockObject_MockObject */ @@ -75,6 +75,7 @@ public function testDoOperationEmptyRepositories() $data = [ 'paths' => ['path/to/app'], 'filePatterns' => ['di' => 'di.xml'], + 'excludePatterns' => ['/\/Test\//'], ]; $files = ['di' => []]; $model = new RepositoryGenerator( From 8db40e1ad65ac65634f4099c8efb2ef2e75d9757 Mon Sep 17 00:00:00 2001 From: Joan He Date: Mon, 26 Oct 2015 12:28:30 -0500 Subject: [PATCH 19/26] MAGETWO-43857: [github] cache types don't properly invalidate all the time #1844 --- .../Theme/Model/Design/Backend/Theme.php | 22 +++++-- .../Unit/Model/Design/Backend/ThemeTest.php | 63 ++++++++----------- app/code/Magento/Theme/etc/config.xml | 5 ++ 3 files changed, 48 insertions(+), 42 deletions(-) diff --git a/app/code/Magento/Theme/Model/Design/Backend/Theme.php b/app/code/Magento/Theme/Model/Design/Backend/Theme.php index 108e82528a064..4917dd31b07ec 100644 --- a/app/code/Magento/Theme/Model/Design/Backend/Theme.php +++ b/app/code/Magento/Theme/Model/Design/Backend/Theme.php @@ -16,6 +16,13 @@ class Theme extends Value */ protected $_design = null; + /** + * Path to config node with list of caches + * + * @var string + */ + const XML_PATH_INVALID_CACHES = 'design/invalid_caches'; + /** * Initialize dependencies * @@ -59,17 +66,22 @@ public function beforeSave() /** * {@inheritdoc} * - * {@inheritdoc}. In addition, it cleans all Magento cache + * {@inheritdoc}. In addition, it sets status 'invalidate' for blocks and other output caches * * @return $this */ public function afterSave() { - parent::afterSave(); + $types = array_keys( + $this->_config->getValue( + self::XML_PATH_INVALID_CACHES, + \Magento\Store\Model\ScopeInterface::SCOPE_STORE + ) + ); if ($this->isValueChanged()) { - $this->_cacheManager->clean(); - $this->_eventManager->dispatch('adminhtml_cache_flush_system'); + $this->cacheTypeList->invalidate($types); } - return $this; + + return parent::afterSave(); } } diff --git a/app/code/Magento/Theme/Test/Unit/Model/Design/Backend/ThemeTest.php b/app/code/Magento/Theme/Test/Unit/Model/Design/Backend/ThemeTest.php index e394482d74865..e83a4e4ca30eb 100644 --- a/app/code/Magento/Theme/Test/Unit/Model/Design/Backend/ThemeTest.php +++ b/app/code/Magento/Theme/Test/Unit/Model/Design/Backend/ThemeTest.php @@ -18,9 +18,9 @@ class ThemeTest extends \PHPUnit_Framework_TestCase protected $model; /** - * @var \Magento\Framework\Model\Context + * @var \Magento\Framework\Model\Context|\PHPUnit_Framework_MockObject_MockObject */ - protected $context; + protected $contextMock; /** * @var \Magento\Framework\View\DesignInterface|\PHPUnit_Framework_MockObject_MockObject @@ -32,16 +32,6 @@ class ThemeTest extends \PHPUnit_Framework_TestCase */ protected $cacheTypeListMock; - /** - * @var \Magento\Framework\Event\ManagerInterface|\PHPUnit_Framework_MockObject_MockObject - */ - protected $eventManagerMock; - - /** - * @var \Magento\Framework\App\CacheInterface | \PHPUnit_Framework_MockObject_MockObject - */ - protected $cacheManagerMock; - /** * @var \Magento\Framework\App\Config\ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject */ @@ -49,33 +39,23 @@ class ThemeTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $objectManager = new ObjectManager($this); - $this->cacheManagerMock = $this->getMockBuilder('Magento\Framework\App\CacheInterface') + $this->contextMock = $this->getMockBuilder('Magento\Framework\Model\Context') ->disableOriginalConstructor() ->getMock(); - $this->eventManagerMock = $this->getMockBuilder('Magento\Framework\Event\ManagerInterface') - ->disableOriginalConstructor() - ->getMock(); - $this->context = $objectManager->getObject( - 'Magento\Framework\Model\Context', - [ - 'cacheManager' => $this->cacheManagerMock, - 'eventDispatcher' => $this->eventManagerMock, - ] - ); - $this->designMock = $this->getMockBuilder('Magento\Framework\View\DesignInterface')->getMock(); $this->cacheTypeListMock = $this->getMockBuilder('Magento\Framework\App\Cache\TypeListInterface') ->disableOriginalConstructor() ->getMock(); + $this->contextMock->expects($this->once()) + ->method('getEventDispatcher') + ->willReturn($this->getMockBuilder('Magento\Framework\Event\ManagerInterface')->getMock()); $this->configMock = $this->getMockBuilder('Magento\Framework\App\Config\ScopeConfigInterface')->getMock(); - - $this->model = $objectManager->getObject( + $this->model = (new ObjectManager($this))->getObject( 'Magento\Theme\Model\Design\Backend\Theme', [ 'design' => $this->designMock, - 'context' => $this->context, + 'context' => $this->contextMock, 'cacheTypeList' => $this->cacheTypeListMock, 'config' => $this->configMock, ] @@ -106,16 +86,25 @@ public function testAfterSave($callNumber, $oldValue) { $this->cacheTypeListMock->expects($this->exactly($callNumber)) ->method('invalidate'); - $this->cacheManagerMock->expects($this->exactly($callNumber)) - ->method('clean'); $this->configMock->expects($this->any()) ->method('getValue') - ->willReturn($oldValue); - if ($callNumber) { - $this->eventManagerMock->expects($this->at(3)) - ->method('dispatch') - ->with('adminhtml_cache_flush_system'); - } + ->willReturnMap( + [ + [ + Theme::XML_PATH_INVALID_CACHES, + \Magento\Store\Model\ScopeInterface::SCOPE_STORE, + null, + ['block_html' => 1, 'layout' => 1, 'translate' => 1] + ], + [ + null, + \Magento\Framework\App\Config\ScopeConfigInterface::SCOPE_TYPE_DEFAULT, + null, + $oldValue + ], + + ] + ); $this->model->setValue('some_value'); $this->assertInstanceOf(get_class($this->model), $this->model->afterSave()); } @@ -124,7 +113,7 @@ public function afterSaveDataProvider() { return [ [0, 'some_value'], - [1, 'other_value'], + [2, 'other_value'], ]; } } diff --git a/app/code/Magento/Theme/etc/config.xml b/app/code/Magento/Theme/etc/config.xml index 332043e56df87..4f25cd7e2abf9 100644 --- a/app/code/Magento/Theme/etc/config.xml +++ b/app/code/Magento/Theme/etc/config.xml @@ -8,6 +8,11 @@ + + + + + Magento Commerce Default Description From 087e32921e51c0d432605378853c189804b43534 Mon Sep 17 00:00:00 2001 From: Joan He Date: Mon, 26 Oct 2015 14:33:43 -0500 Subject: [PATCH 20/26] MAGETWO-41954: Eliminate code generatio in production mode --- .../Setup/Console/Command/DiCompileCommand.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/setup/src/Magento/Setup/Console/Command/DiCompileCommand.php b/setup/src/Magento/Setup/Console/Command/DiCompileCommand.php index 9b2b2f5977de5..8843fb66c2111 100644 --- a/setup/src/Magento/Setup/Console/Command/DiCompileCommand.php +++ b/setup/src/Magento/Setup/Console/Command/DiCompileCommand.php @@ -293,16 +293,21 @@ private function getOperationsConfiguration( array $compiledPathsList, array $dataAttributesIncludePattern ) { + $excludePatterns = []; + foreach ($this->excludedPathsList as $excludedPaths) { + $excludePatterns = array_merge($excludedPaths, $excludePatterns); + } + $operations = [ OperationFactory::PROXY_GENERATOR => [ 'paths' => $compiledPathsList['application'], 'filePatterns' => ['di' => '/\/etc\/([a-zA-Z_]*\/di|di)\.xml$/'], - 'excludePatterns' => ['/\/Test\//'] + 'excludePatterns' => $excludePatterns, ], OperationFactory::REPOSITORY_GENERATOR => [ 'paths' => $compiledPathsList['application'], 'filePatterns' => ['di' => '/\/etc\/([a-zA-Z_]*\/di|di)\.xml$/'], - 'excludePatterns' => ['/\/Test\//'] + 'excludePatterns' => $excludePatterns, ], OperationFactory::DATA_ATTRIBUTES_GENERATOR => [ 'paths' => $compiledPathsList['application'], @@ -315,7 +320,7 @@ private function getOperationsConfiguration( $compiledPathsList['generated_helpers'], ], 'filePatterns' => ['php' => '/\.php$/'], - 'excludePatterns' => ['/\/Test\//'] + 'excludePatterns' => $excludePatterns, ], OperationFactory::INTERCEPTION => [ 'intercepted_paths' => [ From f63bede13c80a1716f1dc02543ffd5085b8738e2 Mon Sep 17 00:00:00 2001 From: Dale Sikkema Date: Tue, 27 Oct 2015 16:20:12 -0500 Subject: [PATCH 21/26] MAGETWO-44189: Does not work to switch the language in the admin area - style fix --- .../backend/Magento_Backend/web/css/source/module/_footer.less | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/design/adminhtml/Magento/backend/Magento_Backend/web/css/source/module/_footer.less b/app/design/adminhtml/Magento/backend/Magento_Backend/web/css/source/module/_footer.less index 7752b6d2feda2..8bed4f0da2136 100644 --- a/app/design/adminhtml/Magento/backend/Magento_Backend/web/css/source/module/_footer.less +++ b/app/design/adminhtml/Magento/backend/Magento_Backend/web/css/source/module/_footer.less @@ -53,8 +53,8 @@ // Copyright .copyright { - text-align: left; margin-bottom: -.2rem; + text-align: left; position: relative; .link-copyright { display: inline-block; From c1e27365c9e15b2396899fbaa36f2ec7dcbd7402 Mon Sep 17 00:00:00 2001 From: Joan He Date: Wed, 28 Oct 2015 10:02:05 -0500 Subject: [PATCH 22/26] MAGETWO-43679: Fixed XML validation happens in production mode --- .../Media/Synchronization/SuccessTest.php | 101 ------------------ .../Model/Attribute/Config/ReaderTest.php | 4 +- .../Unit/Model/Attribute/Config/XsdTest.php | 5 +- .../Config/Model/Config/Structure/Reader.php | 2 +- .../Unit/Model/Address/Config/ReaderTest.php | 4 +- .../Unit/Model/Address/Config/XsdTest.php | 5 +- .../Unit/Model/Template/Config/ReaderTest.php | 8 +- .../Unit/Model/Template/Config/XsdTest.php | 5 +- .../Unit/Model/Config/Integration/XsdTest.php | 5 +- .../Test/Unit/Model/Config/XsdTest.php | 5 +- .../Model/Order/Pdf/Config/ReaderTest.php | 4 +- .../Unit/Model/Order/Pdf/Config/XsdTest.php | 5 +- .../TestCase/AbstractConfigFiles.php | 8 +- .../Config/Structure/Reader/ReaderTest.php | 4 +- .../Modular/AbstractMergedConfigTest.php | 15 ++- .../Integrity/Modular/AclConfigFilesTest.php | 5 +- .../Test/Integrity/Modular/CacheFilesTest.php | 2 +- .../Integrity/Modular/DiConfigFilesTest.php | 2 +- .../Modular/EavAttributesConfigFilesTest.php | 2 +- .../Modular/EventConfigFilesTest.php | 5 +- .../Modular/ExportConfigFilesTest.php | 2 +- .../Modular/ImportConfigFilesTest.php | 2 +- .../Modular/IndexerConfigFilesTest.php | 5 +- .../Catalog/AttributeConfigFilesTest.php | 5 +- .../Customer/AddressFormatsFilesTest.php | 5 +- .../Email/EmailTemplateConfigFilesTest.php | 7 +- .../Magento/Sales/PdfConfigFilesTest.php | 7 +- .../Modular/MviewConfigFilesTest.php | 5 +- .../Modular/ProductOptionsConfigFilesTest.php | 2 +- .../Modular/ProductTypesConfigFilesTest.php | 2 +- .../Modular/ResourcesConfigFilesTest.php | 2 +- .../Modular/RouteConfigFilesTest.php | 28 ++++- .../Integrity/Modular/ViewConfigFilesTest.php | 5 +- .../Test/Integrity/Theme/XmlFilesTest.php | 25 ++++- .../App/Language/CircularDependencyTest.php | 29 ++++- .../ExtensionAttribute/Config/XsdTest.php | 5 +- .../App/Arguments/ValidationState.php | 2 +- .../Framework/App/Config/Initial/Reader.php | 16 ++- .../Magento/Framework/App/Language/Config.php | 21 ++-- .../Test/Unit/Config/Initial/ReaderTest.php | 41 +++++-- .../App/Test/Unit/Language/ConfigTest.php | 20 +++- .../Magento/Framework/Config/AbstractXml.php | 44 ++++---- lib/internal/Magento/Framework/Config/Dom.php | 19 +++- .../Magento/Framework/Config/DomFactory.php | 5 +- .../Framework/Config/Reader/Filesystem.php | 22 ++-- .../Framework/Config/Test/Unit/DomTest.php | 30 ++++-- .../Test/Unit/Reader/FilesystemTest.php | 8 +- .../Config/Test/Unit/ValidationStateTest.php | 8 +- .../Config/ValidationStateInterface.php | 2 +- .../Magento/Framework/Config/View.php | 11 +- .../Indexer/Test/Unit/Config/ReaderTest.php | 4 +- .../Mview/Test/Unit/Config/ReaderTest.php | 4 +- .../ObjectManager/Config/Reader/Dom.php | 8 +- .../Config/Reader/_files/ConfigDomMock.php | 2 +- .../Magento/Framework/Validator/Config.php | 15 +-- .../Validator/Test/Unit/ConfigTest.php | 21 +++- .../Magento/Framework/View/Config.php | 9 +- .../Element/UiComponent/Config/DomMerger.php | 26 +++-- .../Framework/View/PageLayout/Config.php | 12 ++- .../Framework/View/Test/Unit/ConfigTest.php | 2 +- .../View/Test/Unit/PageLayout/ConfigTest.php | 23 +++- 61 files changed, 437 insertions(+), 270 deletions(-) delete mode 100644 app/code/Magento/AdminNotification/Test/Unit/Model/System/Message/Media/Synchronization/SuccessTest.php diff --git a/app/code/Magento/AdminNotification/Test/Unit/Model/System/Message/Media/Synchronization/SuccessTest.php b/app/code/Magento/AdminNotification/Test/Unit/Model/System/Message/Media/Synchronization/SuccessTest.php deleted file mode 100644 index a33e8800f2ece..0000000000000 --- a/app/code/Magento/AdminNotification/Test/Unit/Model/System/Message/Media/Synchronization/SuccessTest.php +++ /dev/null @@ -1,101 +0,0 @@ -_syncFlagMock = $this->getMock( - 'Magento\MediaStorage\Model\File\Storage\Flag', - ['getState', 'getFlagData', 'setState', '__sleep', '__wakeup', 'save'], - [], - '', - false - ); - - $this->_fileStorage = $this->getMock('Magento\MediaStorage\Model\File\Storage\Flag', [], [], '', false); - $this->_fileStorage->expects($this->any())->method('loadSelf')->will($this->returnValue($this->_syncFlagMock)); - - $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $arguments = ['fileStorage' => $this->_fileStorage]; - $this->_model = $objectManagerHelper->getObject( - 'Magento\AdminNotification\Model\System\Message\Media\Synchronization\Success', - $arguments - ); - } - - public function testGetText() - { - $messageText = 'Synchronization of media storages has been completed'; - - $this->assertContains($messageText, (string)$this->_model->getText()); - } - - /** - * @param bool $expectedFirstRun - * @param array $data - * @param int|bool $state - * @return void - * @dataProvider isDisplayedDataProvider - */ - public function testIsDisplayed($expectedFirstRun, $data, $state) - { - $arguments = ['fileStorage' => $this->_fileStorage]; - $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - - $this->_syncFlagMock->expects($this->any())->method('getState')->will($this->returnValue($state)); - $this->_syncFlagMock->expects($this->any())->method('getFlagData')->will($this->returnValue($data)); - - // create new instance to ensure that it hasn't been displayed yet (var $this->_isDisplayed is unset) - /** @var $model \Magento\AdminNotification\Model\System\Message\Media\Synchronization\Success */ - $model = $objectManagerHelper->getObject( - 'Magento\AdminNotification\Model\System\Message\Media\Synchronization\Success', - $arguments - ); - //check first call - $this->assertEquals($expectedFirstRun, $model->isDisplayed()); - //check second call - $this->assertEquals($expectedFirstRun, $model->isDisplayed()); - } - - public function isDisplayedDataProvider() - { - return [ - [false, ['has_errors' => 1], \Magento\MediaStorage\Model\File\Storage\Flag::STATE_FINISHED], - [false, ['has_errors' => true], false], - [true, [], \Magento\MediaStorage\Model\File\Storage\Flag::STATE_FINISHED], - [false, ['has_errors' => 0], \Magento\MediaStorage\Model\File\Storage\Flag::STATE_RUNNING], - [true, ['has_errors' => 0], \Magento\MediaStorage\Model\File\Storage\Flag::STATE_FINISHED] - ]; - } - - public function testGetIdentity() - { - $this->assertEquals('MEDIA_SYNCHRONIZATION_SUCCESS', $this->_model->getIdentity()); - } - - public function testGetSeverity() - { - $severity = \Magento\Framework\Notification\MessageInterface::SEVERITY_MAJOR; - $this->assertEquals($severity, $this->_model->getSeverity()); - } -} diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Attribute/Config/ReaderTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Attribute/Config/ReaderTest.php index 3121a3036b920..eceaee7d0dc29 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Attribute/Config/ReaderTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Attribute/Config/ReaderTest.php @@ -73,7 +73,9 @@ protected function setUp() $this->_schemaLocator = new \Magento\Catalog\Model\Attribute\Config\SchemaLocator($moduleReader); $this->_validationState = $this->getMock('Magento\Framework\Config\ValidationStateInterface'); - $this->_validationState->expects($this->once())->method('isValidated')->will($this->returnValue(false)); + $this->_validationState->expects($this->any()) + ->method('isValidationRequired') + ->willReturn(false); $this->_model = new \Magento\Catalog\Model\Attribute\Config\Reader( $this->_fileResolverMock, diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Attribute/Config/XsdTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Attribute/Config/XsdTest.php index 033cd5038928f..da8c9b003331f 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Attribute/Config/XsdTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Attribute/Config/XsdTest.php @@ -27,7 +27,10 @@ protected function setUp() */ public function testExemplarXml($fixtureXml, array $expectedErrors) { - $dom = new \Magento\Framework\Config\Dom($fixtureXml, [], null, null, '%message%'); + $validationStateMock = $this->getMock('\Magento\Framework\Config\ValidationStateInterface', [], [], '', false); + $validationStateMock->method('isValidationRequired') + ->willReturn(true); + $dom = new \Magento\Framework\Config\Dom($fixtureXml, $validationStateMock, [], null, null, '%message%'); $actualResult = $dom->validate($this->_schemaFile, $actualErrors); $this->assertEquals(empty($expectedErrors), $actualResult); $this->assertEquals($expectedErrors, $actualErrors); diff --git a/app/code/Magento/Config/Model/Config/Structure/Reader.php b/app/code/Magento/Config/Model/Config/Structure/Reader.php index 45c04eeb4f01b..c5a082b32fc21 100644 --- a/app/code/Magento/Config/Model/Config/Structure/Reader.php +++ b/app/code/Magento/Config/Model/Config/Structure/Reader.php @@ -100,7 +100,7 @@ protected function _readFiles($fileList) } } - if ($this->_isValidated) { + if ($this->validationState->isValidationRequired()) { $errors = []; if ($configMerger && !$configMerger->validate($this->_schemaFile, $errors)) { $message = "Invalid Document \n"; diff --git a/app/code/Magento/Customer/Test/Unit/Model/Address/Config/ReaderTest.php b/app/code/Magento/Customer/Test/Unit/Model/Address/Config/ReaderTest.php index 751b2b8cf68b5..558d5845f1f07 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Address/Config/ReaderTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Address/Config/ReaderTest.php @@ -74,7 +74,9 @@ protected function setUp() $this->_schemaLocator = new \Magento\Customer\Model\Address\Config\SchemaLocator($moduleReader); $this->_validationState = $this->getMock('Magento\Framework\Config\ValidationStateInterface'); - $this->_validationState->expects($this->once())->method('isValidated')->will($this->returnValue(false)); + $this->_validationState->expects($this->any()) + ->method('isValidationRequired') + ->willReturn(false); $this->_model = new \Magento\Customer\Model\Address\Config\Reader( $this->_fileResolverMock, diff --git a/app/code/Magento/Customer/Test/Unit/Model/Address/Config/XsdTest.php b/app/code/Magento/Customer/Test/Unit/Model/Address/Config/XsdTest.php index a69261461775b..3b3ac8221cb1a 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Address/Config/XsdTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Address/Config/XsdTest.php @@ -27,7 +27,10 @@ protected function setUp() */ public function testExemplarXml($fixtureXml, array $expectedErrors) { - $dom = new \Magento\Framework\Config\Dom($fixtureXml, [], null, null, '%message%'); + $validationStateMock = $this->getMock('\Magento\Framework\Config\ValidationStateInterface', [], [], '', false); + $validationStateMock->method('isValidationRequired') + ->willReturn(true); + $dom = new \Magento\Framework\Config\Dom($fixtureXml, $validationStateMock, [], null, null, '%message%'); $actualResult = $dom->validate($this->_schemaFile, $actualErrors); $this->assertEquals(empty($expectedErrors), $actualResult); $this->assertEquals($expectedErrors, $actualErrors); diff --git a/app/code/Magento/Email/Test/Unit/Model/Template/Config/ReaderTest.php b/app/code/Magento/Email/Test/Unit/Model/Template/Config/ReaderTest.php index e572b67abee1e..baf28034f78b3 100644 --- a/app/code/Magento/Email/Test/Unit/Model/Template/Config/ReaderTest.php +++ b/app/code/Magento/Email/Test/Unit/Model/Template/Config/ReaderTest.php @@ -69,8 +69,10 @@ protected function setUp() ); $schemaLocator = new \Magento\Email\Model\Template\Config\SchemaLocator($moduleReader); - $validationState = $this->getMock('Magento\Framework\Config\ValidationStateInterface'); - $validationState->expects($this->once())->method('isValidated')->will($this->returnValue(false)); + $validationStateMock = $this->getMock('Magento\Framework\Config\ValidationStateInterface', [], [], '', true); + $validationStateMock->expects($this->any()) + ->method('isValidationRequired') + ->willReturn(false); $this->_moduleDirResolver = $this->getMock( 'Magento\Framework\Module\Dir\ReverseResolver', @@ -109,7 +111,7 @@ protected function setUp() $fileResolver, $this->_converter, $schemaLocator, - $validationState + $validationStateMock ); } diff --git a/app/code/Magento/Email/Test/Unit/Model/Template/Config/XsdTest.php b/app/code/Magento/Email/Test/Unit/Model/Template/Config/XsdTest.php index f2eb7b69f76d8..ed03f792be182 100644 --- a/app/code/Magento/Email/Test/Unit/Model/Template/Config/XsdTest.php +++ b/app/code/Magento/Email/Test/Unit/Model/Template/Config/XsdTest.php @@ -113,7 +113,10 @@ public function mergedXmlDataProvider() */ protected function _testXmlAgainstXsd($fixtureXml, $schemaFile, array $expectedErrors) { - $dom = new \Magento\Framework\Config\Dom($fixtureXml, [], null, null, '%message%'); + $validationStateMock = $this->getMock('\Magento\Framework\Config\ValidationStateInterface', [], [], '', false); + $validationStateMock->method('isValidationRequired') + ->willReturn(true); + $dom = new \Magento\Framework\Config\Dom($fixtureXml, $validationStateMock, [], null, null, '%message%'); $actualResult = $dom->validate($schemaFile, $actualErrors); $this->assertEquals(empty($expectedErrors), $actualResult); $this->assertEquals($expectedErrors, $actualErrors); diff --git a/app/code/Magento/Integration/Test/Unit/Model/Config/Integration/XsdTest.php b/app/code/Magento/Integration/Test/Unit/Model/Config/Integration/XsdTest.php index 5413ec66a33b1..e3988ecdbb156 100644 --- a/app/code/Magento/Integration/Test/Unit/Model/Config/Integration/XsdTest.php +++ b/app/code/Magento/Integration/Test/Unit/Model/Config/Integration/XsdTest.php @@ -30,8 +30,11 @@ protected function setUp() */ public function testExemplarXml($fixtureXml, array $expectedErrors) { + $validationStateMock = $this->getMock('\Magento\Framework\Config\ValidationStateInterface', [], [], '', false); + $validationStateMock->method('isValidationRequired') + ->willReturn(true); $messageFormat = '%message%'; - $dom = new \Magento\Framework\Config\Dom($fixtureXml, [], null, null, $messageFormat); + $dom = new \Magento\Framework\Config\Dom($fixtureXml, $validationStateMock, [], null, null, $messageFormat); $actualResult = $dom->validate($this->_schemaFile, $actualErrors); $this->assertEquals(empty($expectedErrors), $actualResult, "Validation result is invalid."); $this->assertEquals($expectedErrors, $actualErrors, "Validation errors does not match."); diff --git a/app/code/Magento/Integration/Test/Unit/Model/Config/XsdTest.php b/app/code/Magento/Integration/Test/Unit/Model/Config/XsdTest.php index 8e1c4195a34a6..ee833328e24c1 100644 --- a/app/code/Magento/Integration/Test/Unit/Model/Config/XsdTest.php +++ b/app/code/Magento/Integration/Test/Unit/Model/Config/XsdTest.php @@ -30,8 +30,11 @@ protected function setUp() */ public function testExemplarXml($fixtureXml, array $expectedErrors) { + $validationStateMock = $this->getMock('\Magento\Framework\Config\ValidationStateInterface', [], [], '', false); + $validationStateMock->method('isValidationRequired') + ->willReturn(true); $messageFormat = '%message%'; - $dom = new \Magento\Framework\Config\Dom($fixtureXml, [], null, null, $messageFormat); + $dom = new \Magento\Framework\Config\Dom($fixtureXml, $validationStateMock, [], null, null, $messageFormat); $actualResult = $dom->validate($this->_schemaFile, $actualErrors); $this->assertEquals(empty($expectedErrors), $actualResult, "Validation result is invalid."); $this->assertEquals($expectedErrors, $actualErrors, "Validation errors does not match."); diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/Pdf/Config/ReaderTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/Pdf/Config/ReaderTest.php index 50407a1fbd1cf..b00d3207cf4ae 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Order/Pdf/Config/ReaderTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Order/Pdf/Config/ReaderTest.php @@ -74,7 +74,9 @@ protected function setUp() $this->_schemaLocator = new \Magento\Sales\Model\Order\Pdf\Config\SchemaLocator($moduleReader); $this->_validationState = $this->getMock('Magento\Framework\Config\ValidationStateInterface'); - $this->_validationState->expects($this->once())->method('isValidated')->will($this->returnValue(false)); + $this->_validationState->expects($this->any()) + ->method('isValidationRequired') + ->willReturn(false); $this->_model = new \Magento\Sales\Model\Order\Pdf\Config\Reader( $this->_fileResolverMock, diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/Pdf/Config/XsdTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/Pdf/Config/XsdTest.php index df9683026fa7b..01fe130398cb2 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Order/Pdf/Config/XsdTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Order/Pdf/Config/XsdTest.php @@ -55,7 +55,10 @@ public function testFileSchemaByExemplar($fixtureXml, array $expectedErrors) */ protected function _testSchema($schema, $fixtureXml, array $expectedErrors) { - $dom = new \Magento\Framework\Config\Dom($fixtureXml, [], null, null, '%message%'); + $validationStateMock = $this->getMock('\Magento\Framework\Config\ValidationStateInterface', [], [], '', false); + $validationStateMock->method('isValidationRequired') + ->willReturn(true); + $dom = new \Magento\Framework\Config\Dom($fixtureXml, $validationStateMock, [], null, null, '%message%'); $actualResult = $dom->validate($schema, $actualErrors); $this->assertEquals(empty($expectedErrors), $actualResult); $this->assertEquals($expectedErrors, $actualErrors); diff --git a/dev/tests/integration/framework/Magento/TestFramework/TestCase/AbstractConfigFiles.php b/dev/tests/integration/framework/Magento/TestFramework/TestCase/AbstractConfigFiles.php index b6accb73fb662..086b657047d96 100644 --- a/dev/tests/integration/framework/Magento/TestFramework/TestCase/AbstractConfigFiles.php +++ b/dev/tests/integration/framework/Magento/TestFramework/TestCase/AbstractConfigFiles.php @@ -51,7 +51,7 @@ public function setUp() $validateStateMock = $this->getMockBuilder( 'Magento\Framework\Config\ValidationStateInterface' )->disableOriginalConstructor()->getMock(); - $validateStateMock->expects($this->any())->method('isValidated')->will($this->returnValue(true)); + $validateStateMock->expects($this->any())->method('isValidationRequired')->will($this->returnValue(true)); $this->_reader = $this->_objectManager->create( $this->_getReaderClassName(), @@ -79,7 +79,11 @@ public function testXmlConfigFile($file, $skip = false) if ($skip) { $this->markTestSkipped('There are no xml files in the system for this test.'); } - $domConfig = new \Magento\Framework\Config\Dom($file); + $validationStateMock = $this->getMock('\Magento\Framework\Config\ValidationStateInterface', [], [], '', false); + $validationStateMock->method('isValidationRequired') + ->willReturn(false); + $domConfig = new \Magento\Framework\Config\Dom($file, $validationStateMock); + $errors = []; $result = $domConfig->validate($this->_schemaFile, $errors); $message = "Invalid XML-file: {$file}\n"; foreach ($errors as $error) { diff --git a/dev/tests/integration/testsuite/Magento/Paypal/Model/Config/Structure/Reader/ReaderTest.php b/dev/tests/integration/testsuite/Magento/Paypal/Model/Config/Structure/Reader/ReaderTest.php index 03d1d6f247188..274825a41ca5a 100644 --- a/dev/tests/integration/testsuite/Magento/Paypal/Model/Config/Structure/Reader/ReaderTest.php +++ b/dev/tests/integration/testsuite/Magento/Paypal/Model/Config/Structure/Reader/ReaderTest.php @@ -62,7 +62,7 @@ protected function setUp() $this->fileUtility = \Magento\Framework\App\Utility\Files::init(); $this->validationStateMock = $this->getMockBuilder('Magento\Framework\Config\ValidationStateInterface') - ->setMethods(['isValidated']) + ->setMethods(['isValidationRequired']) ->getMockForAbstractClass(); $this->schemaLocatorMock = $this->getMockBuilder('Magento\Config\Model\Config\SchemaLocator') ->disableOriginalConstructor() @@ -72,7 +72,7 @@ protected function setUp() ->getMockForAbstractClass(); $this->validationStateMock->expects($this->atLeastOnce()) - ->method('isValidated') + ->method('isValidationRequired') ->willReturn(false); $this->schemaLocatorMock->expects($this->atLeastOnce()) ->method('getPerFileSchema') diff --git a/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/AbstractMergedConfigTest.php b/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/AbstractMergedConfigTest.php index bc0518559ba9d..051b7e891ace1 100644 --- a/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/AbstractMergedConfigTest.php +++ b/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/AbstractMergedConfigTest.php @@ -39,15 +39,28 @@ public function testMergedConfigFiles() $invalidFiles = []; $files = $this->getConfigFiles(); + $validationStateMock = $this->getMock('\Magento\Framework\Config\ValidationStateInterface', [], [], '', false); + $validationStateMock->method('isValidationRequired') + ->willReturn(false); $mergedConfig = new \Magento\Framework\Config\Dom( '', + $validationStateMock, $this->getIdAttributes() ); foreach ($files as $file) { $content = file_get_contents($file[0]); try { - new \Magento\Framework\Config\Dom($content, $this->getIdAttributes()); + $validationStateMock = $this->getMock( + '\Magento\Framework\Config\ValidationStateInterface', + [], + [], + '', + false + ); + $validationStateMock->method('isValidationRequired') + ->willReturn(true); + new \Magento\Framework\Config\Dom($content, $validationStateMock, $this->getIdAttributes()); //merge won't be performed if file is invalid because of exception thrown $mergedConfig->merge($content); } catch (\Magento\Framework\Config\Dom\ValidationException $e) { diff --git a/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/AclConfigFilesTest.php b/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/AclConfigFilesTest.php index c998094fc963a..9b66e0702c056 100644 --- a/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/AclConfigFilesTest.php +++ b/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/AclConfigFilesTest.php @@ -35,7 +35,10 @@ protected function setUp() */ public function testAclConfigFile($file) { - $domConfig = new \Magento\Framework\Config\Dom(file_get_contents($file)); + $validationStateMock = $this->getMock('\Magento\Framework\Config\ValidationStateInterface', [], [], '', false); + $validationStateMock->method('isValidationRequired') + ->willReturn(true); + $domConfig = new \Magento\Framework\Config\Dom(file_get_contents($file), $validationStateMock); $result = $domConfig->validate($this->_schemeFile, $errors); $message = "Invalid XML-file: {$file}\n"; foreach ($errors as $error) { diff --git a/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/CacheFilesTest.php b/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/CacheFilesTest.php index 430cced2f1a2e..25051e023a5bf 100644 --- a/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/CacheFilesTest.php +++ b/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/CacheFilesTest.php @@ -14,7 +14,7 @@ class CacheFilesTest extends \PHPUnit_Framework_TestCase public function testCacheConfig($area) { $validationStateMock = $this->getMock('Magento\Framework\Config\ValidationStateInterface'); - $validationStateMock->expects($this->any())->method('isValidated')->will($this->returnValue(true)); + $validationStateMock->expects($this->any())->method('isValidationRequired')->will($this->returnValue(true)); $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); diff --git a/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/DiConfigFilesTest.php b/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/DiConfigFilesTest.php index 42b6a74d7e06d..b9c4c7cbb9471 100644 --- a/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/DiConfigFilesTest.php +++ b/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/DiConfigFilesTest.php @@ -108,7 +108,7 @@ public function testMergedDiConfig(array $files) $fileResolverMock = $this->getMock('Magento\Framework\Config\FileResolverInterface'); $fileResolverMock->expects($this->any())->method('read')->will($this->returnValue($files)); $validationStateMock = $this->getMock('Magento\Framework\Config\ValidationStateInterface'); - $validationStateMock->expects($this->any())->method('isValidated')->will($this->returnValue(true)); + $validationStateMock->expects($this->any())->method('isValidationRequired')->will($this->returnValue(true)); /** @var \Magento\Framework\ObjectManager\Config\SchemaLocator $schemaLocator */ $schemaLocator = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( diff --git a/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/EavAttributesConfigFilesTest.php b/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/EavAttributesConfigFilesTest.php index 03111c820d6ed..0a290d04abd53 100644 --- a/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/EavAttributesConfigFilesTest.php +++ b/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/EavAttributesConfigFilesTest.php @@ -25,7 +25,7 @@ public function setUp() ); $validationStateMock = $this->getMock('Magento\Framework\Config\ValidationStateInterface'); - $validationStateMock->expects($this->any())->method('isValidated')->will($this->returnValue(true)); + $validationStateMock->expects($this->any())->method('isValidationRequired')->will($this->returnValue(true)); $fileResolverMock = $this->getMock('Magento\Framework\Config\FileResolverInterface'); $fileResolverMock->expects($this->any())->method('get')->will($this->returnValue($xmlFiles)); $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); diff --git a/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/EventConfigFilesTest.php b/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/EventConfigFilesTest.php index f81c30cc0407c..d1f2fef8a815b 100644 --- a/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/EventConfigFilesTest.php +++ b/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/EventConfigFilesTest.php @@ -25,7 +25,10 @@ protected function setUp() public function testEventConfigFiles($file) { $errors = []; - $dom = new \Magento\Framework\Config\Dom(file_get_contents($file)); + $validationStateMock = $this->getMock('\Magento\Framework\Config\ValidationStateInterface', [], [], '', false); + $validationStateMock->method('isValidationRequired') + ->willReturn(true); + $dom = new \Magento\Framework\Config\Dom(file_get_contents($file), $validationStateMock); $result = $dom->validate($this->_schemaFile, $errors); $message = "Invalid XML-file: {$file}\n"; foreach ($errors as $error) { diff --git a/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/ExportConfigFilesTest.php b/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/ExportConfigFilesTest.php index 6229b7d06c013..00eb532d6b90f 100644 --- a/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/ExportConfigFilesTest.php +++ b/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/ExportConfigFilesTest.php @@ -25,7 +25,7 @@ public function setUp() ); $validationStateMock = $this->getMock('Magento\Framework\Config\ValidationStateInterface'); - $validationStateMock->expects($this->any())->method('isValidated')->will($this->returnValue(true)); + $validationStateMock->expects($this->any())->method('isValidationRequired')->will($this->returnValue(true)); $fileResolverMock = $this->getMock('Magento\Framework\Config\FileResolverInterface'); $fileResolverMock->expects($this->any())->method('get')->will($this->returnValue($xmlFiles)); $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); diff --git a/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/ImportConfigFilesTest.php b/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/ImportConfigFilesTest.php index dd31a3287fce1..61c6c66f79cf5 100644 --- a/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/ImportConfigFilesTest.php +++ b/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/ImportConfigFilesTest.php @@ -25,7 +25,7 @@ public function setUp() ); $validationStateMock = $this->getMock('Magento\Framework\Config\ValidationStateInterface'); - $validationStateMock->expects($this->any())->method('isValidated')->will($this->returnValue(true)); + $validationStateMock->expects($this->any())->method('isValidationRequired')->will($this->returnValue(true)); $fileResolverMock = $this->getMock('Magento\Framework\Config\FileResolverInterface'); $fileResolverMock->expects($this->any())->method('get')->will($this->returnValue($xmlFiles)); $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); diff --git a/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/IndexerConfigFilesTest.php b/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/IndexerConfigFilesTest.php index f12917f9c456d..3f16450ae3e12 100644 --- a/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/IndexerConfigFilesTest.php +++ b/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/IndexerConfigFilesTest.php @@ -36,7 +36,10 @@ protected function setUp() */ public function testIndexerConfigFile($file) { - $domConfig = new \Magento\Framework\Config\Dom(file_get_contents($file)); + $validationStateMock = $this->getMock('\Magento\Framework\Config\ValidationStateInterface', [], [], '', false); + $validationStateMock->method('isValidationRequired') + ->willReturn(true); + $domConfig = new \Magento\Framework\Config\Dom(file_get_contents($file), $validationStateMock); $result = $domConfig->validate($this->schemaFile, $errors); $message = "Invalid XML-file: {$file}\n"; foreach ($errors as $error) { diff --git a/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/Magento/Catalog/AttributeConfigFilesTest.php b/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/Magento/Catalog/AttributeConfigFilesTest.php index a0aaff1b95386..1e4ceac5e7db0 100644 --- a/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/Magento/Catalog/AttributeConfigFilesTest.php +++ b/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/Magento/Catalog/AttributeConfigFilesTest.php @@ -26,7 +26,10 @@ protected function setUp() */ public function testFileFormat($file) { - $dom = new \Magento\Framework\Config\Dom(file_get_contents($file)); + $validationStateMock = $this->getMock('\Magento\Framework\Config\ValidationStateInterface', [], [], '', false); + $validationStateMock->method('isValidationRequired') + ->willReturn(true); + $dom = new \Magento\Framework\Config\Dom(file_get_contents($file), $validationStateMock); $result = $dom->validate($this->_schemaFile, $errors); $this->assertTrue($result, print_r($errors, true)); } diff --git a/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/Magento/Customer/AddressFormatsFilesTest.php b/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/Magento/Customer/AddressFormatsFilesTest.php index e503a543247f8..7cad3da12a066 100644 --- a/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/Magento/Customer/AddressFormatsFilesTest.php +++ b/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/Magento/Customer/AddressFormatsFilesTest.php @@ -27,7 +27,10 @@ protected function setUp() */ public function testFileFormat($file) { - $dom = new \Magento\Framework\Config\Dom(file_get_contents($file)); + $validationStateMock = $this->getMock('\Magento\Framework\Config\ValidationStateInterface', [], [], '', false); + $validationStateMock->method('isValidationRequired') + ->willReturn(true); + $dom = new \Magento\Framework\Config\Dom(file_get_contents($file), $validationStateMock); $result = $dom->validate($this->_schemaFile, $errors); $this->assertTrue($result, print_r($errors, true)); } diff --git a/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/Magento/Email/EmailTemplateConfigFilesTest.php b/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/Magento/Email/EmailTemplateConfigFilesTest.php index 8c667e6d38c49..546db270e1bbf 100644 --- a/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/Magento/Email/EmailTemplateConfigFilesTest.php +++ b/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/Magento/Email/EmailTemplateConfigFilesTest.php @@ -17,7 +17,10 @@ public function testFileFormat($file) { $urnResolver = new \Magento\Framework\Config\Dom\UrnResolver(); $schemaFile = $urnResolver->getRealPath('urn:magento:module:Magento_Email:etc/email_templates.xsd'); - $dom = new \Magento\Framework\Config\Dom(file_get_contents($file)); + $validationStateMock = $this->getMock('\Magento\Framework\Config\ValidationStateInterface', [], [], '', false); + $validationStateMock->method('isValidationRequired') + ->willReturn(true); + $dom = new \Magento\Framework\Config\Dom(file_get_contents($file), $validationStateMock); $result = $dom->validate($schemaFile, $errors); $this->assertTrue($result, print_r($errors, true)); } @@ -78,7 +81,7 @@ public function templateReferenceDataProvider() public function testMergedFormat() { $validationState = $this->getMock('Magento\Framework\Config\ValidationStateInterface'); - $validationState->expects($this->any())->method('isValidated')->will($this->returnValue(true)); + $validationState->expects($this->any())->method('isValidationRequired')->will($this->returnValue(true)); /** @var \Magento\Email\Model\Template\Config\Reader $reader */ $reader = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( 'Magento\Email\Model\Template\Config\Reader', diff --git a/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/Magento/Sales/PdfConfigFilesTest.php b/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/Magento/Sales/PdfConfigFilesTest.php index 1bd81dbb00104..f65f0fab665fe 100644 --- a/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/Magento/Sales/PdfConfigFilesTest.php +++ b/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/Magento/Sales/PdfConfigFilesTest.php @@ -19,7 +19,10 @@ public function testFileFormat($file) ); $schemaFile = $schemaLocator->getPerFileSchema(); - $dom = new \Magento\Framework\Config\Dom(file_get_contents($file)); + $validationStateMock = $this->getMock('\Magento\Framework\Config\ValidationStateInterface', [], [], '', false); + $validationStateMock->method('isValidationRequired') + ->willReturn(true); + $dom = new \Magento\Framework\Config\Dom(file_get_contents($file), $validationStateMock); $result = $dom->validate($schemaFile, $errors); $this->assertTrue($result, print_r($errors, true)); } @@ -35,7 +38,7 @@ public function fileFormatDataProvider() public function testMergedFormat() { $validationState = $this->getMock('Magento\Framework\Config\ValidationStateInterface'); - $validationState->expects($this->any())->method('isValidated')->will($this->returnValue(true)); + $validationState->expects($this->any())->method('isValidationRequired')->will($this->returnValue(true)); /** @var \Magento\Sales\Model\Order\Pdf\Config\Reader $reader */ $reader = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( diff --git a/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/MviewConfigFilesTest.php b/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/MviewConfigFilesTest.php index d112c6d50d389..0393ef43ecd8a 100644 --- a/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/MviewConfigFilesTest.php +++ b/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/MviewConfigFilesTest.php @@ -36,7 +36,10 @@ protected function setUp() */ public function testIndexerConfigFile($file) { - $domConfig = new \Magento\Framework\Config\Dom(file_get_contents($file)); + $validationStateMock = $this->getMock('\Magento\Framework\Config\ValidationStateInterface', [], [], '', false); + $validationStateMock->method('isValidationRequired') + ->willReturn(true); + $domConfig = new \Magento\Framework\Config\Dom(file_get_contents($file), $validationStateMock); $result = $domConfig->validate($this->schemaFile, $errors); $message = "Invalid XML-file: {$file}\n"; foreach ($errors as $error) { diff --git a/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/ProductOptionsConfigFilesTest.php b/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/ProductOptionsConfigFilesTest.php index 17b6e7dab791e..77901d2d25284 100644 --- a/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/ProductOptionsConfigFilesTest.php +++ b/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/ProductOptionsConfigFilesTest.php @@ -31,7 +31,7 @@ protected function setUp() $fileResolverMock = $this->getMock('Magento\Framework\Config\FileResolverInterface'); $fileResolverMock->expects($this->any())->method('get')->will($this->returnValue($xmlFiles)); $validationStateMock = $this->getMock('Magento\Framework\Config\ValidationStateInterface'); - $validationStateMock->expects($this->any())->method('isValidated')->will($this->returnValue(true)); + $validationStateMock->expects($this->any())->method('isValidationRequired')->will($this->returnValue(true)); $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); $this->_model = $objectManager->create( 'Magento\Catalog\Model\ProductOptions\Config\Reader', diff --git a/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/ProductTypesConfigFilesTest.php b/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/ProductTypesConfigFilesTest.php index cf19b7a61da22..0b21c161b144e 100644 --- a/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/ProductTypesConfigFilesTest.php +++ b/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/ProductTypesConfigFilesTest.php @@ -27,7 +27,7 @@ protected function setUp() $fileResolverMock = $this->getMock('Magento\Framework\Config\FileResolverInterface'); $fileResolverMock->expects($this->any())->method('get')->will($this->returnValue($xmlFiles)); $validationStateMock = $this->getMock('Magento\Framework\Config\ValidationStateInterface'); - $validationStateMock->expects($this->any())->method('isValidated')->will($this->returnValue(true)); + $validationStateMock->expects($this->any())->method('isValidationRequired')->will($this->returnValue(true)); $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); $this->_model = $objectManager->create( 'Magento\Catalog\Model\ProductTypes\Config\Reader', diff --git a/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/ResourcesConfigFilesTest.php b/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/ResourcesConfigFilesTest.php index 044605bcc3b05..ad967592e6141 100644 --- a/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/ResourcesConfigFilesTest.php +++ b/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/ResourcesConfigFilesTest.php @@ -27,7 +27,7 @@ protected function setUp() $fileResolverMock = $this->getMock('Magento\Framework\Config\FileResolverInterface'); $fileResolverMock->expects($this->any())->method('get')->will($this->returnValue($xmlFiles)); $validationStateMock = $this->getMock('Magento\Framework\Config\ValidationStateInterface'); - $validationStateMock->expects($this->any())->method('isValidated')->will($this->returnValue(true)); + $validationStateMock->expects($this->any())->method('isValidationRequired')->will($this->returnValue(true)); $deploymentConfigMock = $this->getMock('Magento\Framework\App\DeploymentConfig', [], [], '', false); $deploymentConfigMock->expects($this->any())->method('getConfiguration')->will($this->returnValue([])); $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); diff --git a/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/RouteConfigFilesTest.php b/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/RouteConfigFilesTest.php index 16bc451c47c22..cecf1bf93bdea 100644 --- a/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/RouteConfigFilesTest.php +++ b/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/RouteConfigFilesTest.php @@ -9,6 +9,11 @@ class RouteConfigFilesTest extends \PHPUnit_Framework_TestCase { + /** + * @var \Magento\Framework\Config\ValidationStateInterface + */ + + protected $validationStateMock; /** * attributes represent merging rules * copied from original class \Magento\Framework\App\Route\Config\Reader @@ -36,6 +41,15 @@ class RouteConfigFilesTest extends \PHPUnit_Framework_TestCase protected function setUp() { + $this->validationStateMock = $this->getMock( + '\Magento\Framework\Config\ValidationStateInterface', + [], + [], + '', + false + ); + $this->validationStateMock->method('isValidationRequired') + ->willReturn(true); $urnResolver = new \Magento\Framework\Config\Dom\UrnResolver(); $this->schemaFile = $urnResolver->getRealPath('urn:magento:framework:App/etc/routes.xsd'); $this->mergedSchemaFile = $urnResolver->getRealPath('urn:magento:framework:App/etc/routes_merged.xsd'); @@ -51,12 +65,22 @@ public function testRouteConfigsValidation() $mask = $moduleDir . '/etc/*/routes.xml'; $files = array_merge($files, glob($mask)); } - $mergedConfig = new \Magento\Framework\Config\Dom('', $this->_idAttributes); + $mergedConfig = new \Magento\Framework\Config\Dom( + '', + $this->validationStateMock, + $this->_idAttributes + ); foreach ($files as $file) { $content = file_get_contents($file); try { - new \Magento\Framework\Config\Dom($content, $this->_idAttributes, null, $this->schemaFile); + new \Magento\Framework\Config\Dom( + $content, + $this->validationStateMock, + $this->_idAttributes, + null, + $this->schemaFile + ); //merge won't be performed if file is invalid because of exception thrown $mergedConfig->merge($content); diff --git a/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/ViewConfigFilesTest.php b/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/ViewConfigFilesTest.php index d65b3fa9d7c8d..97fbba4cb671f 100644 --- a/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/ViewConfigFilesTest.php +++ b/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/ViewConfigFilesTest.php @@ -18,7 +18,10 @@ public function testViewConfigFile($file) 'Magento\Framework\View\Xsd\Reader' ); $mergeXsd = $reader->read(); - $domConfig = new \Magento\Framework\Config\Dom($file); + $validationStateMock = $this->getMock('\Magento\Framework\Config\ValidationStateInterface', [], [], '', false); + $validationStateMock->method('isValidationRequired') + ->willReturn(true); + $domConfig = new \Magento\Framework\Config\Dom($file, $validationStateMock); $result = $domConfig->validate( $mergeXsd, $errors diff --git a/dev/tests/integration/testsuite/Magento/Test/Integrity/Theme/XmlFilesTest.php b/dev/tests/integration/testsuite/Magento/Test/Integrity/Theme/XmlFilesTest.php index 95a9bb0d8cb7b..5fcdf88564fba 100644 --- a/dev/tests/integration/testsuite/Magento/Test/Integrity/Theme/XmlFilesTest.php +++ b/dev/tests/integration/testsuite/Magento/Test/Integrity/Theme/XmlFilesTest.php @@ -9,6 +9,24 @@ class XmlFilesTest extends \PHPUnit_Framework_TestCase { + /** + * @var \Magento\Framework\Config\ValidationStateInterface + */ + protected $validationStateMock; + + public function setUp() + { + $this->validationStateMock = $this->getMock( + 'Magento\Framework\Config\ValidationStateInterface', + [], + [], + '', + false + ); + $this->validationStateMock->method('isValidationRequired') + ->willReturn(true); + } + /** * @param string $file * @dataProvider viewConfigFileDataProvider @@ -19,7 +37,10 @@ public function testViewConfigFile($file) 'Magento\Framework\View\Xsd\Reader' ); $mergeXsd = $reader->read(); - $domConfig = new \Magento\Framework\Config\Dom(file_get_contents($file)); + $domConfig = new \Magento\Framework\Config\Dom( + file_get_contents($file), + $this->validationStateMock + ); $errors = []; $result = $domConfig->validate($mergeXsd, $errors); $this->assertTrue($result, "Invalid XML-file: {$file}\n" . join("\n", $errors)); @@ -71,7 +92,7 @@ public function themeConfigFileExistsDataProvider() */ public function testThemeConfigFileSchema($file) { - $domConfig = new \Magento\Framework\Config\Dom(file_get_contents($file)); + $domConfig = new \Magento\Framework\Config\Dom(file_get_contents($file), $this->validationStateMock); $errors = []; $result = $domConfig->validate('urn:magento:framework:Config/etc/theme.xsd', $errors); $this->assertTrue($result, "Invalid XML-file: {$file}\n" . join("\n", $errors)); diff --git a/dev/tests/static/testsuite/Magento/Test/Integrity/App/Language/CircularDependencyTest.php b/dev/tests/static/testsuite/Magento/Test/Integrity/App/Language/CircularDependencyTest.php index d6e27c159ece8..358b6a35af3e3 100644 --- a/dev/tests/static/testsuite/Magento/Test/Integrity/App/Language/CircularDependencyTest.php +++ b/dev/tests/static/testsuite/Magento/Test/Integrity/App/Language/CircularDependencyTest.php @@ -8,7 +8,6 @@ use Magento\Framework\App\Language\Config; use Magento\Framework\Component\ComponentRegistrar; -use Magento\Framework\Config\Dom\UrnResolver; class CircularDependencyTest extends \PHPUnit_Framework_TestCase { @@ -22,12 +21,36 @@ class CircularDependencyTest extends \PHPUnit_Framework_TestCase */ public function testCircularDependencies() { + $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $componentRegistrar = new ComponentRegistrar(); $declaredLanguages = $componentRegistrar->getPaths(ComponentRegistrar::LANGUAGE); - $urnResolver = new UrnResolver(); + $validationStateMock = $this->getMock('\Magento\Framework\Config\ValidationStateInterface', [], [], '', false); + $validationStateMock->method('isValidationRequired') + ->willReturn(true); + $domFactoryMock = $this->getMock('Magento\Framework\Config\DomFactory', [], [], '', false); + $domFactoryMock->expects($this->any()) + ->method('createDom') + ->willReturnCallback( + function ($arguments) use ($validationStateMock) { + return new \Magento\Framework\Config\Dom( + $arguments['xml'], + $validationStateMock, + [], + null, + $arguments['schemaFile'] + ); + } + ); + $packs = []; foreach ($declaredLanguages as $language) { - $languageConfig = new Config(file_get_contents($language . '/language.xml'), $urnResolver); + $languageConfig = $objectManager->getObject( + 'Magento\Framework\App\Language\Config', + [ + 'source' => file_get_contents($language . '/language.xml'), + 'domFactory' => $domFactoryMock + ] + ); $this->packs[$languageConfig->getVendor()][$languageConfig->getPackage()] = $languageConfig; $packs[] = $languageConfig; } diff --git a/lib/internal/Magento/Framework/Api/Test/Unit/ExtensionAttribute/Config/XsdTest.php b/lib/internal/Magento/Framework/Api/Test/Unit/ExtensionAttribute/Config/XsdTest.php index 90658f3120bed..bd2ea71987fc5 100644 --- a/lib/internal/Magento/Framework/Api/Test/Unit/ExtensionAttribute/Config/XsdTest.php +++ b/lib/internal/Magento/Framework/Api/Test/Unit/ExtensionAttribute/Config/XsdTest.php @@ -25,8 +25,11 @@ protected function setUp() */ public function testExemplarXml($fixtureXml, array $expectedErrors) { + $validationStateMock = $this->getMock('\Magento\Framework\Config\ValidationStateInterface', [], [], '', false); + $validationStateMock->method('isValidationRequired') + ->willReturn(true); $messageFormat = '%message%'; - $dom = new \Magento\Framework\Config\Dom($fixtureXml, [], null, null, $messageFormat); + $dom = new \Magento\Framework\Config\Dom($fixtureXml, $validationStateMock, [], null, null, $messageFormat); $actualResult = $dom->validate($this->_schemaFile, $actualErrors); $this->assertEquals($expectedErrors, $actualErrors, "Validation errors does not match."); $this->assertEquals(empty($expectedErrors), $actualResult, "Validation result is invalid."); diff --git a/lib/internal/Magento/Framework/App/Arguments/ValidationState.php b/lib/internal/Magento/Framework/App/Arguments/ValidationState.php index 55c65798c64d7..8af1dedc59c45 100644 --- a/lib/internal/Magento/Framework/App/Arguments/ValidationState.php +++ b/lib/internal/Magento/Framework/App/Arguments/ValidationState.php @@ -27,7 +27,7 @@ public function __construct($appMode) * * @return boolean */ - public function isValidated() + public function isValidationRequired() { return $this->_appMode == \Magento\Framework\App\State::MODE_DEVELOPER; } diff --git a/lib/internal/Magento/Framework/App/Config/Initial/Reader.php b/lib/internal/Magento/Framework/App/Config/Initial/Reader.php index d907d22223e42..33f0c4cfcb376 100644 --- a/lib/internal/Magento/Framework/App/Config/Initial/Reader.php +++ b/lib/internal/Magento/Framework/App/Config/Initial/Reader.php @@ -55,7 +55,7 @@ class Reader * @param \Magento\Framework\Config\FileResolverInterface $fileResolver * @param \Magento\Framework\Config\ConverterInterface $converter * @param SchemaLocator $schemaLocator - * @param \Magento\Framework\Config\ValidationStateInterface $validationState + * @param \Magento\Framework\Config\DomFactory $domFactory * @param string $fileName * @param string $domDocumentClass */ @@ -63,14 +63,13 @@ public function __construct( \Magento\Framework\Config\FileResolverInterface $fileResolver, \Magento\Framework\Config\ConverterInterface $converter, SchemaLocator $schemaLocator, - \Magento\Framework\Config\ValidationStateInterface $validationState, - $fileName = 'config.xml', - $domDocumentClass = 'Magento\Framework\Config\Dom' + \Magento\Framework\Config\DomFactory $domFactory, + $fileName = 'config.xml' ) { - $this->_schemaFile = $validationState->isValidated() ? $schemaLocator->getSchema() : null; + $this->_schemaFile = $schemaLocator->getSchema(); $this->_fileResolver = $fileResolver; $this->_converter = $converter; - $this->_domDocumentClass = $domDocumentClass; + $this->domFactory = $domFactory; $this->_fileName = $fileName; } @@ -99,9 +98,8 @@ public function read() $domDocument = null; foreach ($fileList as $file) { try { - if ($domDocument === null) { - $class = $this->_domDocumentClass; - $domDocument = new $class($file, [], null, $this->_schemaFile); + if (!$domDocument) { + $domDocument = $this->domFactory->createDom(['xml' => $file, 'schemaFile' => $this->_schemaFile]); } else { $domDocument->merge($file); } diff --git a/lib/internal/Magento/Framework/App/Language/Config.php b/lib/internal/Magento/Framework/App/Language/Config.php index 84dfdfe149cbe..8376e47e47cb1 100644 --- a/lib/internal/Magento/Framework/App/Language/Config.php +++ b/lib/internal/Magento/Framework/App/Language/Config.php @@ -16,6 +16,11 @@ class Config /** @var \Magento\Framework\Config\Dom\UrnResolver */ protected $urnResolver; + /** + * @var \Magento\Framework\Config\DomFactory + */ + protected $domFactory; + /** * Data extracted from the configuration file * @@ -28,22 +33,18 @@ class Config * * @param string $source * @param \Magento\Framework\Config\Dom\UrnResolver $urnResolver + * @param \Magento\Framework\Config\DomFactory $domFactory * @throws \Magento\Framework\Exception\LocalizedException */ public function __construct( $source, - \Magento\Framework\Config\Dom\UrnResolver $urnResolver + \Magento\Framework\Config\Dom\UrnResolver $urnResolver, + \Magento\Framework\Config\DomFactory $domFactory ) { $this->urnResolver = $urnResolver; - $config = new \DOMDocument(); - $config->loadXML($source); - $errors = Dom::validateDomDocument($config, $this->getSchemaFile()); - if (!empty($errors)) { - throw new \Magento\Framework\Exception\LocalizedException( - new \Magento\Framework\Phrase("Invalid Document: \n%1", [implode("\n", $errors)]) - ); - } - $this->_data = $this->_extractData($config); + $this->domFactory = $domFactory; + $dom = $this->domFactory->createDom(['xml' => $source, 'schemaFile' => $this->getSchemaFile()]); + $this->_data = $this->_extractData($dom->getDom()); } /** diff --git a/lib/internal/Magento/Framework/App/Test/Unit/Config/Initial/ReaderTest.php b/lib/internal/Magento/Framework/App/Test/Unit/Config/Initial/ReaderTest.php index 4c1fde2796bf5..98b9d81e75b9d 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/Config/Initial/ReaderTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/Config/Initial/ReaderTest.php @@ -20,12 +20,12 @@ class ReaderTest extends \PHPUnit_Framework_TestCase protected $model; /** - * @var \Magento\Framework\Config\FileResolverInterface | \PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\Config\FileResolverInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $fileResolverMock; /** - * @var \Magento\Framework\App\Config\Initial\Converter | \PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\App\Config\Initial\Converter|\PHPUnit_Framework_MockObject_MockObject */ protected $converterMock; @@ -35,15 +35,20 @@ class ReaderTest extends \PHPUnit_Framework_TestCase protected $filePath; /** - * @var \Magento\Framework\Config\ValidationStateInterface | \PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\Config\ValidationStateInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $validationStateMock; /** - * @var \Magento\Framework\App\Config\Initial\SchemaLocator | \PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\App\Config\Initial\SchemaLocator|\PHPUnit_Framework_MockObject_MockObject */ protected $schemaLocatorMock; + /** + * @var \Magento\Framework\Config\DomFactory|\PHPUnit_Framework_MockObject_MockObject + */ + protected $domFactoryMock; + protected function setUp() { $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); @@ -58,6 +63,10 @@ protected function setUp() false ); $this->validationStateMock = $this->getMock('Magento\Framework\Config\ValidationStateInterface'); + $this->validationStateMock->expects($this->any()) + ->method('isValidationRequired') + ->will($this->returnValue(true)); + $this->domFactoryMock = $this->getMock('Magento\Framework\Config\DomFactory', [], [], '', false); } public function testConstructor() @@ -85,6 +94,7 @@ public function testReadNoFiles() public function testReadValidConfig() { $this->createModelAndVerifyConstructor(); + $this->prepareDomFactoryMock(); $testXmlFilesList = [ file_get_contents($this->filePath . 'initial_config1.xml'), file_get_contents($this->filePath . 'initial_config2.xml'), @@ -104,6 +114,24 @@ public function testReadValidConfig() $this->assertEquals($expectedConfig, $this->model->read()); } + private function prepareDomFactoryMock() + { + $validationStateMock = $this->validationStateMock; + $this->domFactoryMock->expects($this->once()) + ->method('createDom') + ->willReturnCallback( + function ($arguments) use ($validationStateMock) { + return new \Magento\Framework\Config\Dom( + $arguments['xml'], + $validationStateMock, + [], + null, + $arguments['schemaFile'] + ); + } + ); + } + /** * @covers \Magento\Framework\App\Config\Initial\Reader::read * @expectedException \Magento\Framework\Exception\LocalizedException @@ -112,6 +140,7 @@ public function testReadValidConfig() public function testReadInvalidConfig() { $this->createModelAndVerifyConstructor(); + $this->prepareDomFactoryMock(); $testXmlFilesList = [ file_get_contents($this->filePath . 'invalid_config.xml'), file_get_contents($this->filePath . 'initial_config2.xml'), @@ -133,17 +162,15 @@ public function testReadInvalidConfig() private function createModelAndVerifyConstructor() { - $this->validationStateMock->expects($this->once())->method('isValidated')->will($this->returnValue(true)); $schemaFile = $this->filePath . 'config.xsd'; $this->schemaLocatorMock->expects($this->once())->method('getSchema')->will($this->returnValue($schemaFile)); - $this->model = $this->objectManager->getObject( 'Magento\Framework\App\Config\Initial\Reader', [ 'fileResolver' => $this->fileResolverMock, 'converter' => $this->converterMock, 'schemaLocator' => $this->schemaLocatorMock, - 'validationState' => $this->validationStateMock + 'domFactory' => $this->domFactoryMock ] ); } diff --git a/lib/internal/Magento/Framework/App/Test/Unit/Language/ConfigTest.php b/lib/internal/Magento/Framework/App/Test/Unit/Language/ConfigTest.php index c69c340fda154..5b2f4270d215b 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/Language/ConfigTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/Language/ConfigTest.php @@ -30,9 +30,27 @@ public function setUp() ->method('getRealPath') ->with('urn:magento:framework:App/Language/package.xsd') ->willReturn($this->urnResolver->getRealPath('urn:magento:framework:App/Language/package.xsd')); + $validationStateMock = $this->getMock('\Magento\Framework\Config\ValidationStateInterface', [], [], '', false); + $validationStateMock->method('isValidationRequired') + ->willReturn(true); + $domFactoryMock = $this->getMock('Magento\Framework\Config\DomFactory', [], [], '', false); + $domFactoryMock->expects($this->once()) + ->method('createDom') + ->willReturnCallback( + function ($arguments) use ($validationStateMock) { + return new \Magento\Framework\Config\Dom( + $arguments['xml'], + $validationStateMock, + [], + null, + $arguments['schemaFile'] + ); + } + ); $this->config = new Config( file_get_contents(__DIR__ . '/_files/language.xml'), - $this->urnResolverMock + $this->urnResolverMock, + $domFactoryMock ); } diff --git a/lib/internal/Magento/Framework/Config/AbstractXml.php b/lib/internal/Magento/Framework/Config/AbstractXml.php index acdd49eeee201..abf16d6cd1778 100644 --- a/lib/internal/Magento/Framework/Config/AbstractXml.php +++ b/lib/internal/Magento/Framework/Config/AbstractXml.php @@ -24,14 +24,23 @@ abstract class AbstractXml */ protected $_domConfig = null; + /** + * @var \Magento\Framework\Config\DomFactory + */ + protected $domFactory; + /** * Instantiate with the list of files to merge * * @param array $configFiles + * @param \Magento\Framework\Config\DomFactory $domFactory * @throws \InvalidArgumentException */ - public function __construct($configFiles) - { + public function __construct( + $configFiles, + \Magento\Framework\Config\DomFactory $domFactory + ) { + $this->domFactory = $domFactory; if (empty($configFiles)) { throw new \InvalidArgumentException('There must be at least one configuration file specified.'); } @@ -81,9 +90,7 @@ protected function _merge($configFiles) ); } } - if ($this->_isRuntimeValidated()) { - $this->_performValidate(); - } + $this->_performValidate(); return $this->_getDomConfigModel()->getDom(); } @@ -96,7 +103,9 @@ protected function _merge($configFiles) */ protected function _performValidate($file = null) { - if (!$this->_getDomConfigModel()->validate($this->getSchemaFile(), $errors)) { + $errors = []; + $this->_getDomConfigModel()->validate($this->getSchemaFile(), $errors); + if (!empty($errors)) { $phrase = (null === $file) ? new \Magento\Framework\Phrase('Invalid Document %1%2', [PHP_EOL, implode("\n", $errors)]) : new \Magento\Framework\Phrase('Invalid XML-file: %1%2%3', [$file, PHP_EOL, implode("\n", $errors)]); @@ -106,16 +115,6 @@ protected function _performValidate($file = null) return $this; } - /** - * Get if xml files must be runtime validated - * - * @return boolean - */ - protected function _isRuntimeValidated() - { - return true; - } - /** * Get Dom configuration model * @@ -125,13 +124,12 @@ protected function _isRuntimeValidated() protected function _getDomConfigModel() { if (null === $this->_domConfig) { - $schemaFile = $this->getPerFileSchemaFile() && - $this->_isRuntimeValidated() ? $this->getPerFileSchemaFile() : null; - $this->_domConfig = new \Magento\Framework\Config\Dom( - $this->_getInitialXml(), - $this->_getIdAttributes(), - null, - $schemaFile + $this->_domConfig = $this->domFactory->createDom( + [ + 'xml' => $this->_getInitialXml(), + 'idAttributes' => $this->_getIdAttributes(), + 'schemaFile' => $this->getPerFileSchemaFile() + ] ); } return $this->_domConfig; diff --git a/lib/internal/Magento/Framework/Config/Dom.php b/lib/internal/Magento/Framework/Config/Dom.php index 4f512fd7820a5..f8e910c79fa36 100644 --- a/lib/internal/Magento/Framework/Config/Dom.php +++ b/lib/internal/Magento/Framework/Config/Dom.php @@ -30,6 +30,11 @@ class Dom */ const ERROR_FORMAT_DEFAULT = "%message%\nLine: %line%\n"; + /** + * @var \Magento\Framework\Config\ValidationStateInterface + */ + private $validationState; + /** * Dom document * @@ -71,7 +76,7 @@ class Dom protected $rootNamespace; /** - * \Magento\Framework\Config\Dom\UrnResolver + * @var \Magento\Framework\Config\Dom\UrnResolver */ private static $urnResolver; @@ -82,6 +87,7 @@ class Dom * The path to ID attribute name should not include any attribute notations or modifiers -- only node names * * @param string $xml + * @param \Magento\Framework\Config\ValidationStateInterface $validationState * @param array $idAttributes * @param string $typeAttributeName * @param string $schemaFile @@ -89,11 +95,13 @@ class Dom */ public function __construct( $xml, + \Magento\Framework\Config\ValidationStateInterface $validationState, array $idAttributes = [], $typeAttributeName = null, $schemaFile = null, $errorFormat = self::ERROR_FORMAT_DEFAULT ) { + $this->validationState = $validationState; $this->schema = $schemaFile; $this->nodeMergingConfig = new Dom\NodeMergingConfig(new Dom\NodePathMatcher(), $idAttributes); $this->typeAttributeName = $typeAttributeName; @@ -353,7 +361,7 @@ protected function _initDom($xml) { $dom = new \DOMDocument(); $dom->loadXML($xml); - if ($this->schema) { + if ($this->validationState->isValidationRequired() && $this->schema) { $errors = $this->validateDomDocument($dom, $this->schema, $this->errorFormat); if (count($errors)) { throw new \Magento\Framework\Config\Dom\ValidationException(implode("\n", $errors)); @@ -371,8 +379,11 @@ protected function _initDom($xml) */ public function validate($schemaFileName, &$errors = []) { - $errors = $this->validateDomDocument($this->dom, $schemaFileName, $this->errorFormat); - return !count($errors); + if ($this->validationState->isValidationRequired()) { + $errors = $this->validateDomDocument($this->dom, $schemaFileName, $this->errorFormat); + return !count($errors); + } + return true; } /** diff --git a/lib/internal/Magento/Framework/Config/DomFactory.php b/lib/internal/Magento/Framework/Config/DomFactory.php index 20be79afd0f4b..48d000c9e02f3 100644 --- a/lib/internal/Magento/Framework/Config/DomFactory.php +++ b/lib/internal/Magento/Framework/Config/DomFactory.php @@ -24,8 +24,9 @@ class DomFactory * * @param \Magento\Framework\ObjectManagerInterface $objectManger */ - public function __construct(\Magento\Framework\ObjectManagerInterface $objectManger) - { + public function __construct( + \Magento\Framework\ObjectManagerInterface $objectManger + ) { $this->_objectManager = $objectManger; } diff --git a/lib/internal/Magento/Framework/Config/Reader/Filesystem.php b/lib/internal/Magento/Framework/Config/Reader/Filesystem.php index 992158c6edf63..bbe3544318f84 100644 --- a/lib/internal/Magento/Framework/Config/Reader/Filesystem.php +++ b/lib/internal/Magento/Framework/Config/Reader/Filesystem.php @@ -63,11 +63,9 @@ class Filesystem implements \Magento\Framework\Config\ReaderInterface protected $_domDocumentClass; /** - * Should configuration be validated - * - * @var bool + * @var \Magento\Framework\Config\ValidationStateInterface */ - protected $_isValidated; + protected $validationState; /** * Constructor @@ -95,10 +93,10 @@ public function __construct( $this->_converter = $converter; $this->_fileName = $fileName; $this->_idAttributes = array_replace($this->_idAttributes, $idAttributes); + $this->validationState = $validationState; $this->_schemaFile = $schemaLocator->getSchema(); - $this->_isValidated = $validationState->isValidated(); - $this->_perFileSchema = $schemaLocator->getPerFileSchema() && - $this->_isValidated ? $schemaLocator->getPerFileSchema() : null; + $this->_perFileSchema = $schemaLocator->getPerFileSchema() && $validationState->isValidationRequired() + ? $schemaLocator->getPerFileSchema() : null; $this->_domDocumentClass = $domDocumentClass; $this->_defaultScope = $defaultScope; } @@ -145,7 +143,7 @@ protected function _readFiles($fileList) ); } } - if ($this->_isValidated) { + if ($this->validationState->isValidationRequired()) { $errors = []; if ($configMerger && !$configMerger->validate($this->_schemaFile, $errors)) { $message = "Invalid Document \n"; @@ -172,7 +170,13 @@ protected function _readFiles($fileList) */ protected function _createConfigMerger($mergerClass, $initialContents) { - $result = new $mergerClass($initialContents, $this->_idAttributes, null, $this->_perFileSchema); + $result = new $mergerClass( + $initialContents, + $this->validationState, + $this->_idAttributes, + null, + $this->_perFileSchema + ); if (!$result instanceof \Magento\Framework\Config\Dom) { throw new \UnexpectedValueException( "Instance of the DOM config merger is expected, got {$mergerClass} instead." diff --git a/lib/internal/Magento/Framework/Config/Test/Unit/DomTest.php b/lib/internal/Magento/Framework/Config/Test/Unit/DomTest.php index d759359f4ef03..abe3ca2a331f4 100644 --- a/lib/internal/Magento/Framework/Config/Test/Unit/DomTest.php +++ b/lib/internal/Magento/Framework/Config/Test/Unit/DomTest.php @@ -7,6 +7,24 @@ class DomTest extends \PHPUnit_Framework_TestCase { + /** + * @var \Magento\Framework\Config\ValidationStateInterface + */ + protected $validationStateMock; + + public function setUp() + { + $this->validationStateMock = $this->getMock( + '\Magento\Framework\Config\ValidationStateInterface', + [], + [], + '', + false + ); + $this->validationStateMock->method('isValidationRequired') + ->willReturn(true); + } + /** * @param string $xmlFile * @param string $newXmlFile @@ -19,7 +37,7 @@ public function testMerge($xmlFile, $newXmlFile, $ids, $typeAttributeName, $expe { $xml = file_get_contents(__DIR__ . "/_files/dom/{$xmlFile}"); $newXml = file_get_contents(__DIR__ . "/_files/dom/{$newXmlFile}"); - $config = new \Magento\Framework\Config\Dom($xml, $ids, $typeAttributeName); + $config = new \Magento\Framework\Config\Dom($xml, $this->validationStateMock, $ids, $typeAttributeName); $config->merge($newXml); $this->assertXmlStringEqualsXmlFile(__DIR__ . "/_files/dom/{$expectedXmlFile}", $config->getDom()->saveXML()); } @@ -87,7 +105,7 @@ public function testMergeException() { $xml = file_get_contents(__DIR__ . "/_files/dom/ambiguous_two.xml"); $newXml = file_get_contents(__DIR__ . "/_files/dom/ambiguous_new_one.xml"); - $config = new \Magento\Framework\Config\Dom($xml); + $config = new \Magento\Framework\Config\Dom($xml, $this->validationStateMock); $config->merge($newXml); } @@ -98,7 +116,7 @@ public function testMergeException() */ public function testValidate($xml, array $expectedErrors) { - $dom = new \Magento\Framework\Config\Dom($xml); + $dom = new \Magento\Framework\Config\Dom($xml, $this->validationStateMock); $actualResult = $dom->validate(__DIR__ . '/_files/sample.xsd', $actualErrors); $this->assertEquals(empty($expectedErrors), $actualResult); $this->assertEquals($expectedErrors, $actualErrors); @@ -125,7 +143,7 @@ public function testValidateCustomErrorFormat() $expectedErrors = [ "Error: `Element 'unknown_node': This element is not expected. Expected is ( node ).`", ]; - $dom = new \Magento\Framework\Config\Dom($xml, [], null, null, $errorFormat); + $dom = new \Magento\Framework\Config\Dom($xml, $this->validationStateMock, [], null, null, $errorFormat); $actualResult = $dom->validate(__DIR__ . '/_files/sample.xsd', $actualErrors); $this->assertFalse($actualResult); $this->assertEquals($expectedErrors, $actualErrors); @@ -139,7 +157,7 @@ public function testValidateCustomErrorFormatInvalid() { $xml = ''; $errorFormat = '%message%,%unknown%'; - $dom = new \Magento\Framework\Config\Dom($xml, [], null, null, $errorFormat); + $dom = new \Magento\Framework\Config\Dom($xml, $this->validationStateMock, [], null, null, $errorFormat); $dom->validate(__DIR__ . '/_files/sample.xsd'); } @@ -147,7 +165,7 @@ public function testValidateUnknownError() { $xml = ''; $schemaFile = __DIR__ . '/_files/sample.xsd'; - $dom = new \Magento\Framework\Config\Dom($xml); + $dom = new \Magento\Framework\Config\Dom($xml, $this->validationStateMock); $domMock = $this->getMock('DOMDocument', ['schemaValidate'], []); $domMock->expects($this->once()) ->method('schemaValidate') diff --git a/lib/internal/Magento/Framework/Config/Test/Unit/Reader/FilesystemTest.php b/lib/internal/Magento/Framework/Config/Test/Unit/Reader/FilesystemTest.php index 57e7a97d57350..7f83867d8275c 100644 --- a/lib/internal/Magento/Framework/Config/Test/Unit/Reader/FilesystemTest.php +++ b/lib/internal/Magento/Framework/Config/Test/Unit/Reader/FilesystemTest.php @@ -104,7 +104,9 @@ public function testReadWithInvalidDom() $this->urnResolver->getRealPath('urn:magento:framework:Config/Test/Unit/_files/reader/schema.xsd') ) ); - $this->_validationStateMock->expects($this->any())->method('isValidated')->will($this->returnValue(true)); + $this->_validationStateMock->expects($this->any()) + ->method('isValidationRequired') + ->willReturn(true); $model = new Filesystem( $this->_fileResolverMock, $this->_converterMock, @@ -133,7 +135,9 @@ public function testReadWithInvalidXml() $this->urnResolver->getRealPath('urn:magento:framework:Config/Test/Unit/_files/reader/schema.xsd') ) ); - $this->_validationStateMock->expects($this->any())->method('isValidated')->will($this->returnValue(true)); + $this->_validationStateMock->expects($this->any()) + ->method('isValidationRequired') + ->willReturn(true); $model = new Filesystem( $this->_fileResolverMock, diff --git a/lib/internal/Magento/Framework/Config/Test/Unit/ValidationStateTest.php b/lib/internal/Magento/Framework/Config/Test/Unit/ValidationStateTest.php index 9e0cf08004e9a..6026273c1fc9c 100644 --- a/lib/internal/Magento/Framework/Config/Test/Unit/ValidationStateTest.php +++ b/lib/internal/Magento/Framework/Config/Test/Unit/ValidationStateTest.php @@ -10,18 +10,18 @@ class ValidationStateTest extends \PHPUnit_Framework_TestCase /** * @param string $appMode * @param boolean $expectedResult - * @dataProvider isValidatedDataProvider + * @dataProvider isValidationRequiredDataProvider */ - public function testIsValidated($appMode, $expectedResult) + public function testIsValidationRequired($appMode, $expectedResult) { $model = new \Magento\Framework\App\Arguments\ValidationState($appMode); - $this->assertEquals($model->isValidated(), $expectedResult); + $this->assertEquals($model->isValidationRequired(), $expectedResult); } /** * @return array */ - public function isValidatedDataProvider() + public function isValidationRequiredDataProvider() { return [ [\Magento\Framework\App\State::MODE_DEVELOPER, true], diff --git a/lib/internal/Magento/Framework/Config/ValidationStateInterface.php b/lib/internal/Magento/Framework/Config/ValidationStateInterface.php index 61f39fb67cc76..1ad9f7b167931 100644 --- a/lib/internal/Magento/Framework/Config/ValidationStateInterface.php +++ b/lib/internal/Magento/Framework/Config/ValidationStateInterface.php @@ -17,5 +17,5 @@ interface ValidationStateInterface * * @return boolean */ - public function isValidated(); + public function isValidationRequired(); } diff --git a/lib/internal/Magento/Framework/Config/View.php b/lib/internal/Magento/Framework/Config/View.php index 98a9614018816..cdf7ec68b72cc 100644 --- a/lib/internal/Magento/Framework/Config/View.php +++ b/lib/internal/Magento/Framework/Config/View.php @@ -9,15 +9,11 @@ */ namespace Magento\Framework\Config; -use Magento\Framework\Config\Dom\UrnResolver; use Magento\Framework\View\Xsd\Reader; use Magento\Framework\View\Xsd\Media\TypeDataExtractorPool; class View extends \Magento\Framework\Config\AbstractXml { - /** @var UrnResolver */ - protected $urnResolver; - /** * @var \Magento\Framework\View\Xsd\Media\TypeDataExtractorPool */ @@ -35,23 +31,22 @@ class View extends \Magento\Framework\Config\AbstractXml /** * @param array $configFiles + * @param DomFactory $domFactory * @param Reader $xsdReader - * @param UrnResolver $urnResolver * @param TypeDataExtractorPool $extractorPool * @param array $xpath */ public function __construct( $configFiles, + DomFactory $domFactory, Reader $xsdReader, - UrnResolver $urnResolver, TypeDataExtractorPool $extractorPool, $xpath = [] ) { $this->xpath = $xpath; $this->extractorPool = $extractorPool; - $this->urnResolver = $urnResolver; $this->xsdReader = $xsdReader; - parent::__construct($configFiles); + parent::__construct($configFiles, $domFactory); } /** diff --git a/lib/internal/Magento/Framework/Indexer/Test/Unit/Config/ReaderTest.php b/lib/internal/Magento/Framework/Indexer/Test/Unit/Config/ReaderTest.php index 54f09ad612880..bff3d9e5264cd 100644 --- a/lib/internal/Magento/Framework/Indexer/Test/Unit/Config/ReaderTest.php +++ b/lib/internal/Magento/Framework/Indexer/Test/Unit/Config/ReaderTest.php @@ -34,7 +34,9 @@ protected function setUp() $this->_converter = $this->getMock('Magento\Framework\Indexer\Config\Converter', ['convert']); $validationState = $this->getMock('Magento\Framework\Config\ValidationStateInterface'); - $validationState->expects($this->once())->method('isValidated')->will($this->returnValue(false)); + $validationState->expects($this->any()) + ->method('isValidationRequired') + ->willReturn(false); $this->_model = new \Magento\Framework\Indexer\Config\Reader( $this->_fileResolverMock, diff --git a/lib/internal/Magento/Framework/Mview/Test/Unit/Config/ReaderTest.php b/lib/internal/Magento/Framework/Mview/Test/Unit/Config/ReaderTest.php index ced986821731c..5f2bf50dac3a9 100644 --- a/lib/internal/Magento/Framework/Mview/Test/Unit/Config/ReaderTest.php +++ b/lib/internal/Magento/Framework/Mview/Test/Unit/Config/ReaderTest.php @@ -44,7 +44,9 @@ protected function setUp() $schemaLocator = new \Magento\Framework\Mview\Config\SchemaLocator($urnResolverMock); $validationState = $this->getMock('Magento\Framework\Config\ValidationStateInterface'); - $validationState->expects($this->once())->method('isValidated')->will($this->returnValue(false)); + $validationState->expects($this->any()) + ->method('isValidationRequired') + ->willReturn(false); $this->_model = new \Magento\Framework\Mview\Config\Reader( $this->_fileResolverMock, diff --git a/lib/internal/Magento/Framework/ObjectManager/Config/Reader/Dom.php b/lib/internal/Magento/Framework/ObjectManager/Config/Reader/Dom.php index 2da29257ff905..8203e4a562d42 100644 --- a/lib/internal/Magento/Framework/ObjectManager/Config/Reader/Dom.php +++ b/lib/internal/Magento/Framework/ObjectManager/Config/Reader/Dom.php @@ -62,6 +62,12 @@ public function __construct( */ protected function _createConfigMerger($mergerClass, $initialContents) { - return new $mergerClass($initialContents, $this->_idAttributes, self::TYPE_ATTRIBUTE, $this->_perFileSchema); + return new $mergerClass( + $initialContents, + $this->validationState, + $this->_idAttributes, + self::TYPE_ATTRIBUTE, + $this->_perFileSchema + ); } } diff --git a/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Config/Reader/_files/ConfigDomMock.php b/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Config/Reader/_files/ConfigDomMock.php index 492fbab763320..fffc1776bb0d9 100644 --- a/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Config/Reader/_files/ConfigDomMock.php +++ b/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Config/Reader/_files/ConfigDomMock.php @@ -15,7 +15,7 @@ class ConfigDomMock extends \PHPUnit_Framework_TestCase * @param $perFileSchema * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function __construct($initialContents, $idAttributes, $typeAttribute, $perFileSchema) + public function __construct($initialContents, $validationState, $idAttributes, $typeAttribute, $perFileSchema) { $this->assertEquals('first content item', $initialContents); $this->assertEquals('xsi:type', $typeAttribute); diff --git a/lib/internal/Magento/Framework/Validator/Config.php b/lib/internal/Magento/Framework/Validator/Config.php index 9b10f61bb596d..b45a12914e790 100644 --- a/lib/internal/Magento/Framework/Validator/Config.php +++ b/lib/internal/Magento/Framework/Validator/Config.php @@ -19,7 +19,6 @@ class Config extends \Magento\Framework\Config\AbstractXml const CONSTRAINT_TYPE_ENTITY = 'entity'; const CONSTRAINT_TYPE_PROPERTY = 'property'; - /**#@-*/ /** @@ -32,22 +31,18 @@ class Config extends \Magento\Framework\Config\AbstractXml */ protected $_builderFactory; - /** @var \Magento\Framework\Config\Dom\UrnResolver */ - protected $urnResolver; - /** * @param array $configFiles + * @param \Magento\Framework\Config\DomFactory $domFactory * @param \Magento\Framework\Validator\UniversalFactory $builderFactory - * @param \Magento\Framework\Config\Dom\UrnResolver $urnResolver */ public function __construct( $configFiles, - \Magento\Framework\Validator\UniversalFactory $builderFactory, - \Magento\Framework\Config\Dom\UrnResolver $urnResolver + \Magento\Framework\Config\DomFactory $domFactory, + \Magento\Framework\Validator\UniversalFactory $builderFactory ) { $this->_builderFactory = $builderFactory; - $this->urnResolver = $urnResolver; - parent::__construct($configFiles); + parent::__construct($configFiles, $domFactory); } /** @@ -407,7 +402,7 @@ protected function _readMethods($children) */ public function getSchemaFile() { - return $this->urnResolver->getRealPath('urn:magento:framework:Validator/etc/validation.xsd'); + return __DIR__ . '/etc/validation.xsd'; } /** diff --git a/lib/internal/Magento/Framework/Validator/Test/Unit/ConfigTest.php b/lib/internal/Magento/Framework/Validator/Test/Unit/ConfigTest.php index 9a9bb9aafcaae..977cfb9adf04f 100644 --- a/lib/internal/Magento/Framework/Validator/Test/Unit/ConfigTest.php +++ b/lib/internal/Magento/Framework/Validator/Test/Unit/ConfigTest.php @@ -55,20 +55,35 @@ protected function _initConfig(array $files = null) new \Magento\Framework\ObjectManager\Relations\Runtime() ); $factory = new \Magento\Framework\ObjectManager\Factory\Dynamic\Developer($config); - $realObjectManager = new \Magento\Framework\ObjectManager\ObjectManager($factory, $config); - $factory->setObjectManager($realObjectManager); - $universalFactory = $realObjectManager->get('Magento\Framework\Validator\UniversalFactory'); + $appObjectManager = new \Magento\Framework\ObjectManager\ObjectManager($factory, $config); + $factory->setObjectManager($appObjectManager); + /** @var \Magento\Framework\Validator\UniversalFactory $universalFactory */ + $universalFactory = $appObjectManager->get('Magento\Framework\Validator\UniversalFactory'); /** @var \Magento\Framework\Config\Dom\UrnResolver $urnResolverMock */ $urnResolverMock = $this->getMock('Magento\Framework\Config\Dom\UrnResolver', [], [], '', false); $urnResolverMock->expects($this->any()) ->method('getRealPath') ->with('urn:magento:framework:Validator/etc/validation.xsd') ->willReturn($this->urnResolver->getRealPath('urn:magento:framework:Validator/etc/validation.xsd')); + $appObjectManager->configure( + [ + 'preferences' => [ + 'Magento\Framework\Config\ValidationStateInterface' => + 'Magento\Framework\App\Arguments\ValidationState', + ], + 'Magento\Framework\App\Arguments\ValidationState' => [ + 'arguments' => [ + 'appMode' => 'developer', + ] + ] + ] + ); $this->_config = $this->_objectManager->getObject( 'Magento\Framework\Validator\Config', [ 'configFiles' => $configFiles, 'builderFactory' => $universalFactory, + 'domFactory' => new \Magento\Framework\Config\DomFactory($appObjectManager), 'urnResolver' => $urnResolverMock ] ); diff --git a/lib/internal/Magento/Framework/View/Config.php b/lib/internal/Magento/Framework/View/Config.php index fb4c687a73176..85126514bb328 100644 --- a/lib/internal/Magento/Framework/View/Config.php +++ b/lib/internal/Magento/Framework/View/Config.php @@ -62,9 +62,6 @@ class Config implements \Magento\Framework\View\ConfigInterface */ protected $fileIteratorFactory; - /** @var \Magento\Framework\Config\ViewFactory */ - protected $viewConfigFactory; - /** * File view factory * @@ -89,7 +86,7 @@ public function __construct( \Magento\Framework\View\Asset\Repository $assetRepo, \Magento\Framework\View\FileSystem $viewFileSystem, \Magento\Framework\Config\FileIteratorFactory $fileIteratorFactory, - \Magento\Framework\Config\ViewFactory $viewConfigFactory, + \Magento\Framework\Config\ViewFactory $viewFactory, $filename = self::CONFIG_FILE_NAME ) { $this->moduleReader = $moduleReader; @@ -97,7 +94,7 @@ public function __construct( $this->assetRepo = $assetRepo; $this->viewFileSystem = $viewFileSystem; $this->fileIteratorFactory = $fileIteratorFactory; - $this->viewConfigFactory = $viewConfigFactory; + $this->viewFactory = $viewFactory; $this->filename = $filename; } @@ -131,7 +128,7 @@ public function getViewConfig(array $params = []) $this->rootDirectory->getRelativePath($themeConfigFile) ); } - $config = $this->viewConfigFactory->create($configFiles); + $config = $this->viewFactory->create($configFiles); $this->viewConfigs[$key] = $config; return $config; diff --git a/lib/internal/Magento/Framework/View/Element/UiComponent/Config/DomMerger.php b/lib/internal/Magento/Framework/View/Element/UiComponent/Config/DomMerger.php index ae7107665b4ae..554fc62e34c23 100644 --- a/lib/internal/Magento/Framework/View/Element/UiComponent/Config/DomMerger.php +++ b/lib/internal/Magento/Framework/View/Element/UiComponent/Config/DomMerger.php @@ -8,6 +8,7 @@ use Magento\Framework\Config\Dom; use Magento\Framework\Config\Dom\UrnResolver; use Magento\Framework\Module\Dir\Reader as DirectoryReader; +use \Magento\Framework\Config\ValidationStateInterface; /** * Class DomMerger @@ -19,6 +20,11 @@ class DomMerger implements DomMergerInterface */ const ERROR_FORMAT_DEFAULT = "Message: %message%\nLine: %line%\n"; + /** + * @var \Magento\Framework\Config\ValidationStateInterface + */ + private $validationState; + /** * Location schema file * @@ -62,20 +68,21 @@ class DomMerger implements DomMergerInterface * Format of $contextXPath: array('/config/ui') * The path to ID attribute name should not include any attribute notations or modifiers -- only node names * - * @param UrnResolver $urnResolver - * @param string $schema Absolute schema file path or URN + * @param ValidationStateInterface $validationState + * @param string $schema * @param bool $isMergeSimpleXMLElement * @param array $contextXPath * @param array $idAttributes */ public function __construct( - UrnResolver $urnResolver, + ValidationStateInterface $validationState, $schema, $isMergeSimpleXMLElement = false, array $contextXPath = [], array $idAttributes = [] ) { - $this->schemaFilePath = $urnResolver->getRealPath($schema); + $this->validationState = $validationState; + $this->schema = $schema; $this->isMergeSimpleXMLElement = $isMergeSimpleXMLElement; $this->contextXPath = $contextXPath; $this->idAttributes = $idAttributes; @@ -315,7 +322,7 @@ public function createDomDocument($xml) { $domDocument = new \DOMDocument(); $domDocument->loadXML($xml); - if ($this->schemaFilePath) { + if ($this->validationState->isValidationRequired() && $this->schema) { $errors = $this->validateDomDocument($domDocument); if (count($errors)) { throw new \Magento\Framework\Exception\LocalizedException( @@ -335,12 +342,12 @@ public function createDomDocument($xml) * @return array of errors * @throws \Exception */ - protected function validateDomDocument(\DOMDocument $domDocument, $schemaFilePath = null) + protected function validateDomDocument(\DOMDocument $domDocument, $schema = null) { - $schemaFilePath = $schemaFilePath !== null ? $schemaFilePath : $this->schemaFilePath; + $schema = $schema !== null ? $schema : $this->schema; libxml_use_internal_errors(true); try { - $errors = \Magento\Framework\Config\Dom::validateDomDocument($domDocument, $schemaFilePath); + $errors = \Magento\Framework\Config\Dom::validateDomDocument($domDocument, $schema); } catch (\Exception $exception) { libxml_use_internal_errors(false); throw $exception; @@ -435,6 +442,9 @@ public function unsetDom() */ public function validate($schemaFilePath = null) { + if (!$this->validationState->isValidationRequired()) { + return []; + } return $this->validateDomDocument($this->getDom(), $schemaFilePath); } } diff --git a/lib/internal/Magento/Framework/View/PageLayout/Config.php b/lib/internal/Magento/Framework/View/PageLayout/Config.php index 31279b31a0616..ce0f173c5d8b3 100644 --- a/lib/internal/Magento/Framework/View/PageLayout/Config.php +++ b/lib/internal/Magento/Framework/View/PageLayout/Config.php @@ -17,14 +17,18 @@ class Config extends \Magento\Framework\Config\AbstractXml /** * Instantiate with the list of files to merge * - * @param \Magento\Framework\Config\Dom\UrnResolver $urnResolver * @param array $configFiles + * @param \Magento\Framework\Config\DomFactory $domFactory + * @param \Magento\Framework\Config\Dom\UrnResolver $urnResolver * @throws \InvalidArgumentException */ - public function __construct($configFiles, \Magento\Framework\Config\Dom\UrnResolver $urnResolver) - { + public function __construct( + $configFiles, + \Magento\Framework\Config\DomFactory $domFactory, + \Magento\Framework\Config\Dom\UrnResolver $urnResolver + ) { $this->urnResolver = $urnResolver; - parent::__construct($configFiles); + parent::__construct($configFiles, $domFactory); } /** diff --git a/lib/internal/Magento/Framework/View/Test/Unit/ConfigTest.php b/lib/internal/Magento/Framework/View/Test/Unit/ConfigTest.php index c6c980ee74c53..dd2270d310a3b 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/ConfigTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/ConfigTest.php @@ -68,7 +68,7 @@ protected function setUp() 'assetRepo' => $this->repositoryMock, 'viewFileSystem' => $this->fileSystemMock, 'fileIteratorFactory' => $this->fileIteratorFactoryMock, - 'viewConfigFactory' => $this->viewConfigFactoryMock + 'viewFactory' => $this->viewConfigFactoryMock ] ); } diff --git a/lib/internal/Magento/Framework/View/Test/Unit/PageLayout/ConfigTest.php b/lib/internal/Magento/Framework/View/Test/Unit/PageLayout/ConfigTest.php index 8bdac494e98a6..2b10c2a26d442 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/PageLayout/ConfigTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/PageLayout/ConfigTest.php @@ -23,6 +23,26 @@ protected function setUp() ->method('getRealPath') ->with('urn:magento:framework:View/PageLayout/etc/layouts.xsd') ->willReturn($urnResolver->getRealPath('urn:magento:framework:View/PageLayout/etc/layouts.xsd')); + $validationStateMock = $this->getMock('\Magento\Framework\Config\ValidationStateInterface', [], [], '', false); + $validationStateMock->method('isValidationRequired') + ->willReturn(true); + $domFactoryMock = $this->getMock('Magento\Framework\Config\DomFactory', [], [], '', false); + $domFactoryMock->expects($this->once()) + ->method('createDom') + ->willReturnCallback( + function ($arguments) use ($validationStateMock) { + // @codingStandardsIgnoreStart + return new \Magento\Framework\Config\Dom( + '' + . '', + $validationStateMock, + ['/page_layouts/layout' => 'id'], + null, + $arguments['schemaFile'] + ); + // @codingStandardsIgnoreEnd + } + ); $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->config = $objectManagerHelper->getObject( 'Magento\Framework\View\PageLayout\Config', @@ -31,7 +51,8 @@ protected function setUp() 'configFiles' => [ 'layouts_one.xml' => file_get_contents(__DIR__ . '/_files/layouts_one.xml'), 'layouts_two.xml' => file_get_contents(__DIR__ . '/_files/layouts_two.xml'), - ] + ], + 'domFactory' => $domFactoryMock ] ); } From 8e7a3307b610c6bb4e11e29534dcc35e4f4272f1 Mon Sep 17 00:00:00 2001 From: Dale Sikkema Date: Wed, 28 Oct 2015 11:37:07 -0500 Subject: [PATCH 23/26] MAGETWO-44681: page cache entries not tagged with "FPC" cache type - use plugin to add cache tag --- .../PageCache/Model/App/PageCachePlugin.php | 31 +++++++++++++++++++ .../Unit/Model/App/PageCachePluginTest.php | 28 +++++++++++++++++ app/code/Magento/PageCache/etc/di.xml | 3 ++ 3 files changed, 62 insertions(+) create mode 100644 app/code/Magento/PageCache/Model/App/PageCachePlugin.php create mode 100644 app/code/Magento/PageCache/Test/Unit/Model/App/PageCachePluginTest.php diff --git a/app/code/Magento/PageCache/Model/App/PageCachePlugin.php b/app/code/Magento/PageCache/Model/App/PageCachePlugin.php new file mode 100644 index 0000000000000..8a5e3b8932d5c --- /dev/null +++ b/app/code/Magento/PageCache/Model/App/PageCachePlugin.php @@ -0,0 +1,31 @@ +getObject('\Magento\PageCache\Model\App\PageCachePlugin'); + $subjectMock = $this->getMockBuilder('\Magento\Framework\App\PageCache\Cache') + ->disableOriginalConstructor() + ->getMock(); + $initTags = ['tag', 'otherTag']; + $result = $plugin->beforeSave($subjectMock, 'data', 'identifier', $initTags); + $tags = isset($result[2]) ? $result[2] : null; + $expectedTags = array_merge($initTags, [Type::CACHE_TAG]); + $this->assertNotNull($tags); + foreach ($expectedTags as $expected) { + $this->assertContains($expected, $tags); + } + } +} diff --git a/app/code/Magento/PageCache/etc/di.xml b/app/code/Magento/PageCache/etc/di.xml index b5a248f714ab9..1543abaa27781 100644 --- a/app/code/Magento/PageCache/etc/di.xml +++ b/app/code/Magento/PageCache/etc/di.xml @@ -10,4 +10,7 @@ + + + From 7de2154aaf07f1d2f22d851ddd6a5b1bff8223e9 Mon Sep 17 00:00:00 2001 From: Joan He Date: Wed, 28 Oct 2015 15:21:23 -0500 Subject: [PATCH 24/26] MAGETWO-37820: [GITHUB] Preference in the wrong di.xml file #1291 --- app/code/Magento/Bundle/Setup/InstallData.php | 10 +- .../Product/Attribute/Edit/Tab/Advanced.php | 8 +- .../Adminhtml/Product/Attribute/Grid.php | 6 +- .../Catalog/Model/Attribute/Source/Scopes.php | 8 +- .../Model/Product/Attribute/Backend/Price.php | 8 +- .../Catalog/Model/ResourceModel/Attribute.php | 2 +- .../Model/ResourceModel/Eav/Attribute.php | 8 +- .../ResourceModel/Setup/PropertyMapper.php | 2 +- .../Magento/Catalog/Setup/CategorySetup.php | 104 +++++++++--------- .../Model/ResourceModel/Eav/AttributeTest.php | 10 +- .../CatalogUrlRewrite/Setup/InstallData.php | 8 +- .../Model/ConfigurableAttributeHandler.php | 2 +- .../Model/Product/Type/Configurable.php | 2 +- .../Downloadable/Setup/InstallData.php | 6 +- .../Attribute/ScopedAttributeInterface.php | 15 +++ .../Eav/Model/Entity/Setup/PropertyMapper.php | 6 +- app/code/Magento/Msrp/Setup/InstallData.php | 4 +- .../Model/ResourceModel/Catalog/Product.php | 2 +- .../Magento/Swatches/Setup/InstallData.php | 2 +- app/code/Magento/Tax/Setup/InstallData.php | 2 +- .../Adminhtml/Product/AttributeTest.php | 2 +- .../Product/Attribute/Backend/PriceTest.php | 6 +- 22 files changed, 118 insertions(+), 105 deletions(-) create mode 100644 app/code/Magento/Eav/Model/Entity/Attribute/ScopedAttributeInterface.php diff --git a/app/code/Magento/Bundle/Setup/InstallData.php b/app/code/Magento/Bundle/Setup/InstallData.php index 0df0acd57343b..57a3ab0851e78 100644 --- a/app/code/Magento/Bundle/Setup/InstallData.php +++ b/app/code/Magento/Bundle/Setup/InstallData.php @@ -86,7 +86,7 @@ public function install(ModuleDataSetupInterface $setup, ModuleContextInterface 'input' => '', 'class' => '', 'source' => '', - 'global' => \Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_GLOBAL, + 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_GLOBAL, 'visible' => true, 'required' => true, 'user_defined' => false, @@ -112,7 +112,7 @@ public function install(ModuleDataSetupInterface $setup, ModuleContextInterface 'input' => '', 'class' => '', 'source' => '', - 'global' => \Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_GLOBAL, + 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_GLOBAL, 'visible' => false, 'required' => true, 'user_defined' => false, @@ -137,7 +137,7 @@ public function install(ModuleDataSetupInterface $setup, ModuleContextInterface 'input' => '', 'class' => '', 'source' => '', - 'global' => \Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_GLOBAL, + 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_GLOBAL, 'visible' => false, 'required' => true, 'user_defined' => false, @@ -164,7 +164,7 @@ public function install(ModuleDataSetupInterface $setup, ModuleContextInterface 'input' => 'select', 'class' => '', 'source' => 'Magento\Bundle\Model\Product\Attribute\Source\Price\View', - 'global' => \Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_GLOBAL, + 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_GLOBAL, 'visible' => true, 'required' => true, 'user_defined' => false, @@ -190,7 +190,7 @@ public function install(ModuleDataSetupInterface $setup, ModuleContextInterface 'input' => '', 'class' => '', 'source' => '', - 'global' => \Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_GLOBAL, + 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_GLOBAL, 'visible' => false, 'required' => true, 'user_defined' => false, diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Edit/Tab/Advanced.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Edit/Tab/Advanced.php index 5ed9016a59f6a..db69fe00f5cfb 100644 --- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Edit/Tab/Advanced.php +++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Edit/Tab/Advanced.php @@ -213,14 +213,14 @@ protected function _prepareForm() } $scopes = [ - \Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_STORE => __('Store View'), - \Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_WEBSITE => __('Website'), - \Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_GLOBAL => __('Global'), + \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE => __('Store View'), + \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_WEBSITE => __('Website'), + \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_GLOBAL => __('Global'), ]; if ($attributeObject->getAttributeCode() == 'status' || $attributeObject->getAttributeCode() == 'tax_class_id' ) { - unset($scopes[\Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_STORE]); + unset($scopes[\Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE]); } $fieldset->addField( diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Grid.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Grid.php index b2619647601b9..575a12c430826 100644 --- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Grid.php +++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Grid.php @@ -83,9 +83,9 @@ protected function _prepareColumns() 'index' => 'is_global', 'type' => 'options', 'options' => [ - \Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_STORE => __('Store View'), - \Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_WEBSITE => __('Web Site'), - \Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_GLOBAL => __('Global'), + \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE => __('Store View'), + \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_WEBSITE => __('Web Site'), + \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_GLOBAL => __('Global'), ], 'align' => 'center' ], diff --git a/app/code/Magento/Catalog/Model/Attribute/Source/Scopes.php b/app/code/Magento/Catalog/Model/Attribute/Source/Scopes.php index f471a47432063..62e02652527d2 100644 --- a/app/code/Magento/Catalog/Model/Attribute/Source/Scopes.php +++ b/app/code/Magento/Catalog/Model/Attribute/Source/Scopes.php @@ -5,7 +5,7 @@ */ namespace Magento\Catalog\Model\Attribute\Source; -use \Magento\Catalog\Model\ResourceModel\Eav\Attribute; +use \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface; class Scopes implements \Magento\Framework\Data\OptionSourceInterface { @@ -16,15 +16,15 @@ public function toOptionArray() { return [ [ - 'value' => Attribute::SCOPE_STORE, + 'value' => ScopedAttributeInterface::SCOPE_STORE, 'label' => __('Store View'), ], [ - 'value' => Attribute::SCOPE_WEBSITE, + 'value' => ScopedAttributeInterface::SCOPE_WEBSITE, 'label' => __('Web Site'), ], [ - 'value' => Attribute::SCOPE_GLOBAL, + 'value' => ScopedAttributeInterface::SCOPE_GLOBAL, 'label' => __('Global'), ], ]; diff --git a/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Price.php b/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Price.php index ed6612507d290..9dc0dce6f518b 100644 --- a/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Price.php +++ b/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Price.php @@ -5,6 +5,8 @@ */ namespace Magento\Catalog\Model\Product\Attribute\Backend; +use \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface; + /** * Catalog product price attribute backend model * @@ -91,9 +93,9 @@ public function setAttribute($attribute) public function setScope($attribute) { if ($this->_helper->isPriceGlobal()) { - $attribute->setIsGlobal(\Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_GLOBAL); + $attribute->setIsGlobal(ScopedAttributeInterface::SCOPE_GLOBAL); } else { - $attribute->setIsGlobal(\Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_WEBSITE); + $attribute->setIsGlobal(ScopedAttributeInterface::SCOPE_WEBSITE); } return $this; @@ -118,7 +120,7 @@ public function afterSave($object) return $this; } - if ($this->getAttribute()->getIsGlobal() == \Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_WEBSITE) { + if ($this->getAttribute()->getIsGlobal() == ScopedAttributeInterface::SCOPE_WEBSITE) { $baseCurrency = $this->_config->getValue( \Magento\Directory\Model\Currency::XML_PATH_CURRENCY_BASE, 'default' diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Attribute.php b/app/code/Magento/Catalog/Model/ResourceModel/Attribute.php index dd522da588864..ec7bfafeee1dd 100644 --- a/app/code/Magento/Catalog/Model/ResourceModel/Attribute.php +++ b/app/code/Magento/Catalog/Model/ResourceModel/Attribute.php @@ -86,7 +86,7 @@ protected function _clearUselessAttributeValues(\Magento\Framework\Model\Abstrac if ($object->isScopeGlobal() && isset( $origData['is_global'] - ) && \Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_GLOBAL != $origData['is_global'] + ) && \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_GLOBAL != $origData['is_global'] ) { $attributeStoreIds = array_keys($this->_storeManager->getStores()); if (!empty($attributeStoreIds)) { diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Eav/Attribute.php b/app/code/Magento/Catalog/Model/ResourceModel/Eav/Attribute.php index 2f4d6769131bd..cde304b004ac4 100644 --- a/app/code/Magento/Catalog/Model/ResourceModel/Eav/Attribute.php +++ b/app/code/Magento/Catalog/Model/ResourceModel/Eav/Attribute.php @@ -32,14 +32,8 @@ * @SuppressWarnings(PHPMD.ExcessiveClassComplexity) */ class Attribute extends \Magento\Eav\Model\Entity\Attribute implements - \Magento\Catalog\Api\Data\ProductAttributeInterface + \Magento\Catalog\Api\Data\ProductAttributeInterface, \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface { - const SCOPE_STORE = 0; - - const SCOPE_GLOBAL = 1; - - const SCOPE_WEBSITE = 2; - const MODULE_NAME = 'Magento_Catalog'; const ENTITY = 'catalog_eav_attribute'; diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Setup/PropertyMapper.php b/app/code/Magento/Catalog/Model/ResourceModel/Setup/PropertyMapper.php index b7d5bbb301efd..2f2814b5affaa 100644 --- a/app/code/Magento/Catalog/Model/ResourceModel/Setup/PropertyMapper.php +++ b/app/code/Magento/Catalog/Model/ResourceModel/Setup/PropertyMapper.php @@ -26,7 +26,7 @@ public function map(array $input, $entityTypeId) 'is_global' => $this->_getValue( $input, 'global', - \Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_GLOBAL + \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_GLOBAL ), 'is_visible' => $this->_getValue($input, 'visible', 1), 'is_searchable' => $this->_getValue($input, 'searchable', 0), diff --git a/app/code/Magento/Catalog/Setup/CategorySetup.php b/app/code/Magento/Catalog/Setup/CategorySetup.php index 0efc0ac08375a..23d14d9c7cf77 100644 --- a/app/code/Magento/Catalog/Setup/CategorySetup.php +++ b/app/code/Magento/Catalog/Setup/CategorySetup.php @@ -78,7 +78,7 @@ public function getDefaultEntities() 'label' => 'Name', 'input' => 'text', 'sort_order' => 1, - 'global' => \Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_STORE, + 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE, 'group' => 'General Information', ], 'is_active' => [ @@ -87,7 +87,7 @@ public function getDefaultEntities() 'input' => 'select', 'source' => 'Magento\Eav\Model\Entity\Attribute\Source\Boolean', 'sort_order' => 2, - 'global' => \Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_STORE, + 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE, 'group' => 'General Information', ], 'description' => [ @@ -96,7 +96,7 @@ public function getDefaultEntities() 'input' => 'textarea', 'required' => false, 'sort_order' => 4, - 'global' => \Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_STORE, + 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE, 'wysiwyg_enabled' => true, 'is_html_allowed_on_front' => true, 'group' => 'General Information', @@ -108,7 +108,7 @@ public function getDefaultEntities() 'backend' => 'Magento\Catalog\Model\Category\Attribute\Backend\Image', 'required' => false, 'sort_order' => 5, - 'global' => \Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_STORE, + 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE, 'group' => 'General Information', ], 'meta_title' => [ @@ -117,7 +117,7 @@ public function getDefaultEntities() 'input' => 'text', 'required' => false, 'sort_order' => 6, - 'global' => \Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_STORE, + 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE, 'group' => 'General Information', ], 'meta_keywords' => [ @@ -126,7 +126,7 @@ public function getDefaultEntities() 'input' => 'textarea', 'required' => false, 'sort_order' => 7, - 'global' => \Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_STORE, + 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE, 'group' => 'General Information', ], 'meta_description' => [ @@ -135,7 +135,7 @@ public function getDefaultEntities() 'input' => 'textarea', 'required' => false, 'sort_order' => 8, - 'global' => \Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_STORE, + 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE, 'group' => 'General Information', ], 'display_mode' => [ @@ -145,7 +145,7 @@ public function getDefaultEntities() 'source' => 'Magento\Catalog\Model\Category\Attribute\Source\Mode', 'required' => false, 'sort_order' => 10, - 'global' => \Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_STORE, + 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE, 'group' => 'Display Settings', ], 'landing_page' => [ @@ -155,7 +155,7 @@ public function getDefaultEntities() 'source' => 'Magento\Catalog\Model\Category\Attribute\Source\Page', 'required' => false, 'sort_order' => 20, - 'global' => \Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_STORE, + 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE, 'group' => 'Display Settings', ], 'is_anchor' => [ @@ -211,7 +211,7 @@ public function getDefaultEntities() 'source' => 'Magento\Theme\Model\Theme\Source\Theme', 'required' => false, 'sort_order' => 10, - 'global' => \Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_STORE, + 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE, 'group' => 'Custom Design', ], 'custom_design_from' => [ @@ -221,7 +221,7 @@ public function getDefaultEntities() 'backend' => 'Magento\Catalog\Model\Attribute\Backend\Startdate', 'required' => false, 'sort_order' => 30, - 'global' => \Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_STORE, + 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE, 'group' => 'Custom Design', ], 'custom_design_to' => [ @@ -231,7 +231,7 @@ public function getDefaultEntities() 'backend' => 'Magento\Eav\Model\Entity\Attribute\Backend\Datetime', 'required' => false, 'sort_order' => 40, - 'global' => \Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_STORE, + 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE, 'group' => 'Custom Design', ], 'page_layout' => [ @@ -241,7 +241,7 @@ public function getDefaultEntities() 'source' => 'Magento\Catalog\Model\Category\Attribute\Source\Layout', 'required' => false, 'sort_order' => 50, - 'global' => \Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_STORE, + 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE, 'group' => 'Custom Design', ], 'custom_layout_update' => [ @@ -251,7 +251,7 @@ public function getDefaultEntities() 'backend' => 'Magento\Catalog\Model\Attribute\Backend\Customlayoutupdate', 'required' => false, 'sort_order' => 60, - 'global' => \Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_STORE, + 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE, 'group' => 'Custom Design', ], 'level' => [ @@ -278,7 +278,7 @@ public function getDefaultEntities() 'backend' => 'Magento\Catalog\Model\Category\Attribute\Backend\Sortby', 'sort_order' => 40, 'input_renderer' => 'Magento\Catalog\Block\Adminhtml\Category\Helper\Sortby\Available', - 'global' => \Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_STORE, + 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE, 'group' => 'Display Settings', ], 'default_sort_by' => [ @@ -289,7 +289,7 @@ public function getDefaultEntities() 'backend' => 'Magento\Catalog\Model\Category\Attribute\Backend\Sortby', 'sort_order' => 50, 'input_renderer' => 'Magento\Catalog\Block\Adminhtml\Category\Helper\Sortby\DefaultSortby', - 'global' => \Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_STORE, + 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE, 'group' => 'Display Settings', ], 'include_in_menu' => [ @@ -299,7 +299,7 @@ public function getDefaultEntities() 'source' => 'Magento\Eav\Model\Entity\Attribute\Source\Boolean', 'default' => '1', 'sort_order' => 10, - 'global' => \Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_STORE, + 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE, 'group' => 'General Information', ], 'custom_use_parent_settings' => [ @@ -309,7 +309,7 @@ public function getDefaultEntities() 'source' => 'Magento\Eav\Model\Entity\Attribute\Source\Boolean', 'required' => false, 'sort_order' => 5, - 'global' => \Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_STORE, + 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE, 'group' => 'Custom Design', ], 'custom_apply_to_products' => [ @@ -319,7 +319,7 @@ public function getDefaultEntities() 'source' => 'Magento\Eav\Model\Entity\Attribute\Source\Boolean', 'required' => false, 'sort_order' => 6, - 'global' => \Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_STORE, + 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE, 'group' => 'Custom Design', ], 'filter_price_range' => [ @@ -329,7 +329,7 @@ public function getDefaultEntities() 'required' => false, 'sort_order' => 51, 'input_renderer' => 'Magento\Catalog\Block\Adminhtml\Category\Helper\Pricestep', - 'global' => \Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_STORE, + 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE, 'group' => 'Display Settings', ], ], @@ -347,7 +347,7 @@ public function getDefaultEntities() 'input' => 'text', 'frontend_class' => 'validate-length maximum-length-255', 'sort_order' => 1, - 'global' => \Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_STORE, + 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE, 'searchable' => true, 'visible_in_advanced_search' => true, 'used_in_product_listing' => true, @@ -370,7 +370,7 @@ public function getDefaultEntities() 'label' => 'Description', 'input' => 'textarea', 'sort_order' => 3, - 'global' => \Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_STORE, + 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE, 'searchable' => true, 'comparable' => true, 'wysiwyg_enabled' => true, @@ -382,7 +382,7 @@ public function getDefaultEntities() 'label' => 'Short Description', 'input' => 'textarea', 'sort_order' => 4, - 'global' => \Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_STORE, + 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE, 'searchable' => true, 'comparable' => true, 'wysiwyg_enabled' => true, @@ -399,7 +399,7 @@ public function getDefaultEntities() 'input' => 'price', 'backend' => 'Magento\Catalog\Model\Product\Attribute\Backend\Price', 'sort_order' => 1, - 'global' => \Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_WEBSITE, + 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_WEBSITE, 'searchable' => true, 'filterable' => true, 'visible_in_advanced_search' => true, @@ -415,7 +415,7 @@ public function getDefaultEntities() 'backend' => 'Magento\Catalog\Model\Product\Attribute\Backend\Price', 'required' => false, 'sort_order' => 3, - 'global' => \Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_WEBSITE, + 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_WEBSITE, 'used_in_product_listing' => true, 'apply_to' => 'simple,virtual', 'group' => 'Prices', @@ -430,7 +430,7 @@ public function getDefaultEntities() 'backend' => 'Magento\Catalog\Model\Attribute\Backend\Startdate', 'required' => false, 'sort_order' => 4, - 'global' => \Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_WEBSITE, + 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_WEBSITE, 'used_in_product_listing' => true, 'apply_to' => 'simple,virtual', 'group' => 'Prices', @@ -445,7 +445,7 @@ public function getDefaultEntities() 'backend' => 'Magento\Eav\Model\Entity\Attribute\Backend\Datetime', 'required' => false, 'sort_order' => 5, - 'global' => \Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_WEBSITE, + 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_WEBSITE, 'used_in_product_listing' => true, 'apply_to' => 'simple,virtual', 'group' => 'Prices', @@ -461,7 +461,7 @@ public function getDefaultEntities() 'required' => false, 'user_defined' => true, 'sort_order' => 6, - 'global' => \Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_WEBSITE, + 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_WEBSITE, 'apply_to' => 'simple,virtual', 'group' => 'Prices', 'is_used_in_grid' => true, @@ -501,7 +501,7 @@ public function getDefaultEntities() 'input' => 'text', 'required' => false, 'sort_order' => 20, - 'global' => \Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_STORE, + 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE, 'group' => 'Meta Information', 'is_used_in_grid' => true, 'is_visible_in_grid' => false, @@ -513,7 +513,7 @@ public function getDefaultEntities() 'input' => 'textarea', 'required' => false, 'sort_order' => 30, - 'global' => \Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_STORE, + 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE, 'group' => 'Meta Information', 'is_used_in_grid' => true, 'is_visible_in_grid' => false, @@ -527,7 +527,7 @@ public function getDefaultEntities() 'note' => 'Maximum 255 chars', 'class' => 'validate-length maximum-length-255', 'sort_order' => 40, - 'global' => \Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_STORE, + 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE, 'group' => 'Meta Information', 'is_used_in_grid' => true, 'is_visible_in_grid' => false, @@ -541,7 +541,7 @@ public function getDefaultEntities() 'input_renderer' => 'Magento\Catalog\Block\Adminhtml\Product\Helper\Form\BaseImage', 'required' => false, 'sort_order' => 0, - 'global' => \Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_STORE, + 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE, 'used_in_product_listing' => true, 'group' => 'General', ], @@ -552,7 +552,7 @@ public function getDefaultEntities() 'frontend' => 'Magento\Catalog\Model\Product\Attribute\Frontend\Image', 'required' => false, 'sort_order' => 2, - 'global' => \Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_STORE, + 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE, 'used_in_product_listing' => true, 'group' => 'Images', ], @@ -563,7 +563,7 @@ public function getDefaultEntities() 'frontend' => 'Magento\Catalog\Model\Product\Attribute\Frontend\Image', 'required' => false, 'sort_order' => 3, - 'global' => \Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_STORE, + 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE, 'used_in_product_listing' => true, 'group' => 'Images', ], @@ -584,7 +584,7 @@ public function getDefaultEntities() 'backend' => 'Magento\Catalog\Model\Product\Attribute\Backend\Tierprice', 'required' => false, 'sort_order' => 7, - 'global' => \Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_WEBSITE, + 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_WEBSITE, 'apply_to' => 'simple,virtual', 'group' => 'Prices', ], @@ -610,7 +610,7 @@ public function getDefaultEntities() 'backend' => 'Magento\Catalog\Model\Attribute\Backend\Startdate', 'required' => false, 'sort_order' => 7, - 'global' => \Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_WEBSITE, + 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_WEBSITE, 'used_in_product_listing' => true, 'is_used_in_grid' => true, 'is_visible_in_grid' => false, @@ -623,7 +623,7 @@ public function getDefaultEntities() 'backend' => 'Magento\Eav\Model\Entity\Attribute\Backend\Datetime', 'required' => false, 'sort_order' => 8, - 'global' => \Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_WEBSITE, + 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_WEBSITE, 'used_in_product_listing' => true, 'is_used_in_grid' => true, 'is_visible_in_grid' => false, @@ -643,7 +643,7 @@ public function getDefaultEntities() 'input' => 'select', 'source' => 'Magento\Catalog\Model\Product\Attribute\Source\Status', 'sort_order' => 9, - 'global' => \Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_WEBSITE, + 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_WEBSITE, 'searchable' => true, 'used_in_product_listing' => true, ], @@ -653,7 +653,7 @@ public function getDefaultEntities() 'input' => 'price', 'required' => false, 'sort_order' => 8, - 'global' => \Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_STORE, + 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE, 'visible' => false, 'apply_to' => 'simple,virtual', 'group' => 'Prices', @@ -665,7 +665,7 @@ public function getDefaultEntities() 'source' => 'Magento\Catalog\Model\Product\Visibility', 'default' => '4', 'sort_order' => 12, - 'global' => \Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_STORE, + 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE, ], 'custom_design' => [ 'type' => 'varchar', @@ -674,7 +674,7 @@ public function getDefaultEntities() 'source' => 'Magento\Theme\Model\Theme\Source\Theme', 'required' => false, 'sort_order' => 1, - 'global' => \Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_STORE, + 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE, 'group' => 'Design', 'is_used_in_grid' => true, 'is_visible_in_grid' => false, @@ -687,7 +687,7 @@ public function getDefaultEntities() 'backend' => 'Magento\Catalog\Model\Attribute\Backend\Startdate', 'required' => false, 'sort_order' => 2, - 'global' => \Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_STORE, + 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE, 'group' => 'Design', 'is_used_in_grid' => true, 'is_visible_in_grid' => false, @@ -700,7 +700,7 @@ public function getDefaultEntities() 'backend' => 'Magento\Eav\Model\Entity\Attribute\Backend\Datetime', 'required' => false, 'sort_order' => 3, - 'global' => \Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_STORE, + 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE, 'group' => 'Design', 'is_used_in_grid' => true, 'is_visible_in_grid' => false, @@ -713,7 +713,7 @@ public function getDefaultEntities() 'backend' => 'Magento\Catalog\Model\Attribute\Backend\Customlayoutupdate', 'required' => false, 'sort_order' => 4, - 'global' => \Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_STORE, + 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE, 'group' => 'Design', ], 'page_layout' => [ @@ -723,7 +723,7 @@ public function getDefaultEntities() 'source' => 'Magento\Catalog\Model\Product\Attribute\Source\Layout', 'required' => false, 'sort_order' => 5, - 'global' => \Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_STORE, + 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE, 'group' => 'Design', 'is_used_in_grid' => true, 'is_visible_in_grid' => false, @@ -732,7 +732,7 @@ public function getDefaultEntities() 'category_ids' => [ 'type' => 'static', 'label' => 'Categories', - 'global' => \Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_GLOBAL, + 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_GLOBAL, 'backend' => 'Magento\Catalog\Model\Product\Attribute\Backend\Category', 'input_renderer' => 'Magento\Catalog\Block\Adminhtml\Product\Helper\Form\Category', 'required' => false, @@ -748,7 +748,7 @@ public function getDefaultEntities() 'required' => false, 'default' => 'container2', 'sort_order' => 6, - 'global' => \Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_STORE, + 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE, 'group' => 'Design', ], 'required_options' => [ @@ -772,7 +772,7 @@ public function getDefaultEntities() 'input' => 'text', 'required' => false, 'sort_order' => 16, - 'global' => \Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_STORE, + 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE, 'visible' => false, 'used_in_product_listing' => true, ], @@ -782,7 +782,7 @@ public function getDefaultEntities() 'input' => 'text', 'required' => false, 'sort_order' => 17, - 'global' => \Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_STORE, + 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE, 'visible' => false, 'used_in_product_listing' => true, ], @@ -792,7 +792,7 @@ public function getDefaultEntities() 'input' => 'text', 'required' => false, 'sort_order' => 18, - 'global' => \Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_STORE, + 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE, 'visible' => false, 'used_in_product_listing' => true, ], @@ -816,7 +816,7 @@ public function getDefaultEntities() 'input' => 'select', 'source' => 'Magento\Catalog\Model\Product\Attribute\Source\Countryofmanufacture', 'required' => false, - 'global' => \Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_WEBSITE, + 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_WEBSITE, 'visible' => true, 'user_defined' => false, 'searchable' => false, @@ -838,7 +838,7 @@ public function getDefaultEntities() 'input' => 'select', 'input_renderer' => 'Magento\CatalogInventory\Block\Adminhtml\Form\Field\Stock', 'source' => 'Magento\\CatalogInventory\\Model\\Source\\Stock', - 'global' => \Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_GLOBAL, + 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_GLOBAL, 'default' => \Magento\CatalogInventory\Model\Stock::STOCK_IN_STOCK, 'user_defined' => false, 'visible' => true, diff --git a/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Eav/AttributeTest.php b/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Eav/AttributeTest.php index ab8d0328ca609..38e97bbc10877 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Eav/AttributeTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Eav/AttributeTest.php @@ -8,8 +8,6 @@ namespace Magento\Catalog\Test\Unit\Model\ResourceModel\Eav; -use \Magento\Catalog\Model\ResourceModel\Eav\Attribute; - class AttributeTest extends \PHPUnit_Framework_TestCase { /** @@ -131,9 +129,9 @@ public function testIndexerAfterSaveScopeChangeAttribute() { $this->_processor->expects($this->once())->method('markIndexerAsInvalid'); - $this->_model->setOrigData('is_global', \Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_STORE); + $this->_model->setOrigData('is_global', \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE); $this->_model->setOrigData('used_in_product_listing', 1); - $this->_model->setIsGlobal(\Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_GLOBAL); + $this->_model->setIsGlobal(\Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_GLOBAL); $this->_model->afterSave(); } @@ -172,7 +170,7 @@ public function testGetScopeGlobal() 'indexerEavProcessor' => $this->_eavProcessor, 'resource' => $this->resourceMock, 'data' => [ - 'is_global' => Attribute::SCOPE_GLOBAL + 'is_global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_GLOBAL ] ] ); @@ -190,7 +188,7 @@ public function testGetScopeWebiste() 'indexerEavProcessor' => $this->_eavProcessor, 'resource' => $this->resourceMock, 'data' => [ - 'is_global' => Attribute::SCOPE_WEBSITE + 'is_global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_WEBSITE ] ] ); diff --git a/app/code/Magento/CatalogUrlRewrite/Setup/InstallData.php b/app/code/Magento/CatalogUrlRewrite/Setup/InstallData.php index 56ae25a6bbbb5..46a0f9bea7985 100644 --- a/app/code/Magento/CatalogUrlRewrite/Setup/InstallData.php +++ b/app/code/Magento/CatalogUrlRewrite/Setup/InstallData.php @@ -50,7 +50,7 @@ public function install(ModuleDataSetupInterface $setup, ModuleContextInterface 'input' => 'text', 'required' => false, 'sort_order' => 3, - 'global' => \Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_STORE, + 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE, 'group' => 'General Information', ] ); @@ -62,7 +62,7 @@ public function install(ModuleDataSetupInterface $setup, ModuleContextInterface 'type' => 'varchar', 'required' => false, 'sort_order' => 17, - 'global' => \Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_STORE, + 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE, 'visible' => false, 'group' => 'General Information', ] @@ -77,7 +77,7 @@ public function install(ModuleDataSetupInterface $setup, ModuleContextInterface 'input' => 'text', 'required' => false, 'sort_order' => 10, - 'global' => \Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_STORE, + 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE, 'used_in_product_listing' => true, 'group' => 'Search Engine Optimization', 'is_used_in_grid' => true, @@ -93,7 +93,7 @@ public function install(ModuleDataSetupInterface $setup, ModuleContextInterface 'type' => 'varchar', 'required' => false, 'sort_order' => 11, - 'global' => \Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_STORE, + 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE, 'visible' => false, ] ); diff --git a/app/code/Magento/ConfigurableProduct/Model/ConfigurableAttributeHandler.php b/app/code/Magento/ConfigurableProduct/Model/ConfigurableAttributeHandler.php index 239f6d697d745..a2f9231a79dd5 100644 --- a/app/code/Magento/ConfigurableProduct/Model/ConfigurableAttributeHandler.php +++ b/app/code/Magento/ConfigurableProduct/Model/ConfigurableAttributeHandler.php @@ -40,7 +40,7 @@ public function getApplicableAttributes() 1 )->addFieldToFilter( 'is_global', - \Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_GLOBAL + \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_GLOBAL ); } diff --git a/app/code/Magento/ConfigurableProduct/Model/Product/Type/Configurable.php b/app/code/Magento/ConfigurableProduct/Model/Product/Type/Configurable.php index 85eae4dae7cda..93f2588d21459 100644 --- a/app/code/Magento/ConfigurableProduct/Model/Product/Type/Configurable.php +++ b/app/code/Magento/ConfigurableProduct/Model/Product/Type/Configurable.php @@ -248,7 +248,7 @@ public function getParentIdsByChild($childId) */ public function canUseAttribute(\Magento\Catalog\Model\ResourceModel\Eav\Attribute $attribute) { - return $attribute->getIsGlobal() == \Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_GLOBAL && + return $attribute->getIsGlobal() == \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_GLOBAL && $attribute->getIsVisible() && $attribute->usesSource() && $attribute->getIsUserDefined(); diff --git a/app/code/Magento/Downloadable/Setup/InstallData.php b/app/code/Magento/Downloadable/Setup/InstallData.php index 28b92d361ce2c..594f08fad3d9f 100644 --- a/app/code/Magento/Downloadable/Setup/InstallData.php +++ b/app/code/Magento/Downloadable/Setup/InstallData.php @@ -56,7 +56,7 @@ public function install(ModuleDataSetupInterface $setup, ModuleContextInterface 'input' => '', 'class' => '', 'source' => '', - 'global' => \Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_GLOBAL, + 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_GLOBAL, 'visible' => false, 'required' => true, 'user_defined' => false, @@ -82,7 +82,7 @@ public function install(ModuleDataSetupInterface $setup, ModuleContextInterface 'input' => '', 'class' => '', 'source' => '', - 'global' => \Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_STORE, + 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE, 'visible' => false, 'required' => true, 'user_defined' => false, @@ -107,7 +107,7 @@ public function install(ModuleDataSetupInterface $setup, ModuleContextInterface 'input' => '', 'class' => '', 'source' => '', - 'global' => \Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_STORE, + 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE, 'visible' => false, 'required' => true, 'user_defined' => false, diff --git a/app/code/Magento/Eav/Model/Entity/Attribute/ScopedAttributeInterface.php b/app/code/Magento/Eav/Model/Entity/Attribute/ScopedAttributeInterface.php new file mode 100644 index 0000000000000..2b2412fe05bb4 --- /dev/null +++ b/app/code/Magento/Eav/Model/Entity/Attribute/ScopedAttributeInterface.php @@ -0,0 +1,15 @@ + $this->_getValue($input, 'default'), 'is_unique' => $this->_getValue($input, 'unique', 0), 'note' => $this->_getValue($input, 'note'), - 'is_global' => $this->_getValue($input, 'global', Attribute::SCOPE_GLOBAL) + 'is_global' => $this->_getValue( + $input, + 'global', + \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_GLOBAL + ) ]; } } diff --git a/app/code/Magento/Msrp/Setup/InstallData.php b/app/code/Magento/Msrp/Setup/InstallData.php index 080637c88e3df..e9e76b117c11a 100644 --- a/app/code/Magento/Msrp/Setup/InstallData.php +++ b/app/code/Magento/Msrp/Setup/InstallData.php @@ -60,7 +60,7 @@ public function install(ModuleDataSetupInterface $setup, ModuleContextInterface 'label' => 'Manufacturer\'s Suggested Retail Price', 'type' => 'decimal', 'input' => 'price', - 'global' => \Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_WEBSITE, + 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_WEBSITE, 'visible' => true, 'required' => false, 'user_defined' => false, @@ -86,7 +86,7 @@ public function install(ModuleDataSetupInterface $setup, ModuleContextInterface 'input' => 'select', 'source' => 'Magento\Msrp\Model\Product\Attribute\Source\Type\Price', 'source_model' => 'Magento\Msrp\Model\Product\Attribute\Source\Type\Price', - 'global' => \Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_WEBSITE, + 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_WEBSITE, 'visible' => true, 'required' => false, 'user_defined' => false, diff --git a/app/code/Magento/Sitemap/Model/ResourceModel/Catalog/Product.php b/app/code/Magento/Sitemap/Model/ResourceModel/Catalog/Product.php index 5a93ef13583fe..302d9689e1e4e 100644 --- a/app/code/Magento/Sitemap/Model/ResourceModel/Catalog/Product.php +++ b/app/code/Magento/Sitemap/Model/ResourceModel/Catalog/Product.php @@ -234,7 +234,7 @@ protected function _getAttribute($attributeCode) 'attribute_id' => $attribute->getId(), 'table' => $attribute->getBackend()->getTable(), 'is_global' => $attribute->getIsGlobal() == - \Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_GLOBAL, + \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_GLOBAL, 'backend_type' => $attribute->getBackendType(), ]; } diff --git a/app/code/Magento/Swatches/Setup/InstallData.php b/app/code/Magento/Swatches/Setup/InstallData.php index ac3a902095471..a97bd81215e37 100644 --- a/app/code/Magento/Swatches/Setup/InstallData.php +++ b/app/code/Magento/Swatches/Setup/InstallData.php @@ -60,7 +60,7 @@ public function install(ModuleDataSetupInterface $setup, ModuleContextInterface 'frontend' => 'Magento\Catalog\Model\Product\Attribute\Frontend\Image', 'required' => false, 'sort_order' => 3, - 'global' => \Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_STORE, + 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE, 'used_in_product_listing' => true ] ); diff --git a/app/code/Magento/Tax/Setup/InstallData.php b/app/code/Magento/Tax/Setup/InstallData.php index 75f636abb3ee2..2400deda8bd40 100644 --- a/app/code/Magento/Tax/Setup/InstallData.php +++ b/app/code/Magento/Tax/Setup/InstallData.php @@ -56,7 +56,7 @@ public function install(ModuleDataSetupInterface $setup, ModuleContextInterface 'input' => 'select', 'class' => '', 'source' => 'Magento\Tax\Model\TaxClass\Source\Product', - 'global' => \Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_WEBSITE, + 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_WEBSITE, 'visible' => true, 'required' => false, 'user_defined' => false, diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/AttributeTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/AttributeTest.php index 664fdee219872..479ffa633c865 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/AttributeTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/AttributeTest.php @@ -249,7 +249,7 @@ protected function _translate($string) protected function _getAttributeData() { return [ - 'is_global' => \Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_STORE, + 'is_global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE, 'default_value_text' => '0', 'default_value_yesno' => '0', 'default_value_date' => '', diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Attribute/Backend/PriceTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Attribute/Backend/PriceTest.php index 5a8a484ac6ef3..1ba80dc05c41e 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Attribute/Backend/PriceTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Attribute/Backend/PriceTest.php @@ -36,12 +36,12 @@ public function testSetScopeDefault() { /* validate result of setAttribute */ $this->assertEquals( - \Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_GLOBAL, + \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_GLOBAL, $this->_model->getAttribute()->getIsGlobal() ); $this->_model->setScope($this->_model->getAttribute()); $this->assertEquals( - \Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_GLOBAL, + \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_GLOBAL, $this->_model->getAttribute()->getIsGlobal() ); } @@ -53,7 +53,7 @@ public function testSetScope() { $this->_model->setScope($this->_model->getAttribute()); $this->assertEquals( - \Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_WEBSITE, + \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_WEBSITE, $this->_model->getAttribute()->getIsGlobal() ); } From a33e4d35995d1e129fbba11859f305569990ebd6 Mon Sep 17 00:00:00 2001 From: Joan He Date: Wed, 28 Oct 2015 15:59:35 -0500 Subject: [PATCH 25/26] MAGETWO-37820: [GITHUB] Preference in the wrong di.xml file #1291 - fixed typo --- app/code/Magento/Catalog/Setup/CategorySetup.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Catalog/Setup/CategorySetup.php b/app/code/Magento/Catalog/Setup/CategorySetup.php index 23d14d9c7cf77..c0dddb276cb1d 100644 --- a/app/code/Magento/Catalog/Setup/CategorySetup.php +++ b/app/code/Magento/Catalog/Setup/CategorySetup.php @@ -837,7 +837,7 @@ public function getDefaultEntities() 'label' => 'Quantity', 'input' => 'select', 'input_renderer' => 'Magento\CatalogInventory\Block\Adminhtml\Form\Field\Stock', - 'source' => 'Magento\\CatalogInventory\\Model\\Source\\Stock', + 'source' => 'Magento\CatalogInventory\Model\Source\Stock', 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_GLOBAL, 'default' => \Magento\CatalogInventory\Model\Stock::STOCK_IN_STOCK, 'user_defined' => false, From 3cd46941dfeeed4990fd3f03f2038381c82d1605 Mon Sep 17 00:00:00 2001 From: Dale Sikkema Date: Wed, 28 Oct 2015 19:36:12 -0500 Subject: [PATCH 26/26] MAGETWO-44681: page cache entries not tagged with "FPC" cache type - fix static tests --- .../Magento/PageCache/Model/App/PageCachePlugin.php | 10 ++++++---- .../Test/Unit/Model/App/PageCachePluginTest.php | 2 ++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/app/code/Magento/PageCache/Model/App/PageCachePlugin.php b/app/code/Magento/PageCache/Model/App/PageCachePlugin.php index 8a5e3b8932d5c..afb43a516f4eb 100644 --- a/app/code/Magento/PageCache/Model/App/PageCachePlugin.php +++ b/app/code/Magento/PageCache/Model/App/PageCachePlugin.php @@ -12,11 +12,13 @@ class PageCachePlugin * Attach FPC tag to all saved entries to enable cache type management * * @param \Magento\Framework\App\PageCache\Cache $subject - * @param $data - * @param $identifier - * @param array $tags - * @param null $lifeTime + * @param string $data + * @param string $identifier + * @param string[] $tags + * @param int|null $lifeTime * @return array + * + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function beforeSave( \Magento\Framework\App\PageCache\Cache $subject, diff --git a/app/code/Magento/PageCache/Test/Unit/Model/App/PageCachePluginTest.php b/app/code/Magento/PageCache/Test/Unit/Model/App/PageCachePluginTest.php index b0a115f3860fc..5f10bbc747954 100644 --- a/app/code/Magento/PageCache/Test/Unit/Model/App/PageCachePluginTest.php +++ b/app/code/Magento/PageCache/Test/Unit/Model/App/PageCachePluginTest.php @@ -4,6 +4,8 @@ * See COPYING.txt for license details. */ +namespace Magento\PageCache\Test\Unit\Model\App; + use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; use Magento\PageCache\Model\Cache\Type;