diff --git a/app/code/Magento/Authorization/Model/Resource/Role.php b/app/code/Magento/Authorization/Model/Resource/Role.php
index e1bd73002af02..2e00f3fb209f3 100644
--- a/app/code/Magento/Authorization/Model/Resource/Role.php
+++ b/app/code/Magento/Authorization/Model/Resource/Role.php
@@ -32,17 +32,19 @@ class Role extends \Magento\Framework\Model\Resource\Db\AbstractDb
protected $dateTime;
/**
- * @param \Magento\Framework\App\Resource $resource
+ * @param \Magento\Framework\Model\Resource\Db\Context $context
* @param \Magento\Framework\App\CacheInterface $cache
* @param \Magento\Framework\Stdlib\DateTime $dateTime
+ * @param string|null $resourcePrefix
*/
public function __construct(
- \Magento\Framework\App\Resource $resource,
+ \Magento\Framework\Model\Resource\Db\Context $context,
\Magento\Framework\App\CacheInterface $cache,
- \Magento\Framework\Stdlib\DateTime $dateTime
+ \Magento\Framework\Stdlib\DateTime $dateTime,
+ $resourcePrefix = null
) {
$this->dateTime = $dateTime;
- parent::__construct($resource);
+ parent::__construct($context, $resourcePrefix);
$this->_cache = $cache->getFrontend();
}
diff --git a/app/code/Magento/Authorization/Model/Resource/Rules.php b/app/code/Magento/Authorization/Model/Resource/Rules.php
index 373c1f82f3120..e298055e8fca1 100644
--- a/app/code/Magento/Authorization/Model/Resource/Rules.php
+++ b/app/code/Magento/Authorization/Model/Resource/Rules.php
@@ -38,21 +38,23 @@ class Rules extends \Magento\Framework\Model\Resource\Db\AbstractDb
protected $_logger;
/**
- * @param \Magento\Framework\App\Resource $resource
+ * @param \Magento\Framework\Model\Resource\Db\Context $context
* @param \Magento\Framework\Acl\Builder $aclBuilder
* @param \Psr\Log\LoggerInterface $logger
* @param \Magento\Framework\Acl\RootResource $rootResource
* @param \Magento\Framework\Acl\CacheInterface $aclCache
+ * @param string|null $resourcePrefix
*/
public function __construct(
- \Magento\Framework\App\Resource $resource,
+ \Magento\Framework\Model\Resource\Db\Context $context,
\Magento\Framework\Acl\Builder $aclBuilder,
\Psr\Log\LoggerInterface $logger,
\Magento\Framework\Acl\RootResource $rootResource,
- \Magento\Framework\Acl\CacheInterface $aclCache
+ \Magento\Framework\Acl\CacheInterface $aclCache,
+ $resourcePrefix = null
) {
$this->_aclBuilder = $aclBuilder;
- parent::__construct($resource);
+ parent::__construct($context, $resourcePrefix);
$this->_rootResource = $rootResource;
$this->_aclCache = $aclCache;
$this->_logger = $logger;
diff --git a/app/code/Magento/Bundle/Model/Resource/Bundle.php b/app/code/Magento/Bundle/Model/Resource/Bundle.php
index 7a6b0d006ac6a..02365f5e3ff38 100644
--- a/app/code/Magento/Bundle/Model/Resource/Bundle.php
+++ b/app/code/Magento/Bundle/Model/Resource/Bundle.php
@@ -18,15 +18,25 @@ class Bundle extends \Magento\Framework\Model\Resource\Db\AbstractDb
protected $_productRelation;
/**
- * @param \Magento\Framework\App\Resource $resource
+ * @var \Magento\Quote\Model\Resource\Quote
+ */
+ protected $quoteResource;
+
+ /**
+ * @param \Magento\Framework\Model\Resource\Db\Context $context
* @param \Magento\Catalog\Model\Resource\Product\Relation $productRelation
+ * @param \Magento\Quote\Model\Resource\Quote $quoteResource
+ * @param null $resourcePrefix
*/
public function __construct(
- \Magento\Framework\App\Resource $resource,
- \Magento\Catalog\Model\Resource\Product\Relation $productRelation
+ \Magento\Framework\Model\Resource\Db\Context $context,
+ \Magento\Catalog\Model\Resource\Product\Relation $productRelation,
+ \Magento\Quote\Model\Resource\Quote $quoteResource,
+ $resourcePrefix = null
) {
- parent::__construct($resource);
+ parent::__construct($context, $resourcePrefix);
$this->_productRelation = $productRelation;
+ $this->quoteResource = $quoteResource;
}
/**
@@ -83,8 +93,10 @@ public function getSelectionsData($productId)
*/
public function dropAllQuoteChildItems($productId)
{
- $quoteItemIds = $this->_getReadAdapter()->fetchCol(
- $this->_getReadAdapter()->select()->from(
+ $select = $this->quoteResource->getReadConnection()->select();
+ $adapter = $select->getAdapter();
+ $quoteItemIds = $adapter->fetchCol(
+ $select->from(
$this->getTable('quote_item'),
['item_id']
)->where(
@@ -94,7 +106,7 @@ public function dropAllQuoteChildItems($productId)
);
if ($quoteItemIds) {
- $this->_getWriteAdapter()->delete(
+ $adapter->delete(
$this->getTable('quote_item'),
['parent_item_id IN(?)' => $quoteItemIds]
);
diff --git a/app/code/Magento/Bundle/Model/Resource/Option.php b/app/code/Magento/Bundle/Model/Resource/Option.php
index 6e7b744f1d32a..90e45fed81b20 100644
--- a/app/code/Magento/Bundle/Model/Resource/Option.php
+++ b/app/code/Magento/Bundle/Model/Resource/Option.php
@@ -18,14 +18,16 @@ class Option extends \Magento\Framework\Model\Resource\Db\AbstractDb
private $validator;
/**
- * @param \Magento\Framework\App\Resource $resource
+ * @param \Magento\Framework\Model\Resource\Db\Context $context
* @param \Magento\Bundle\Model\Option\Validator $validator
+ * @param string|null $resourcePrefix
*/
public function __construct(
- \Magento\Framework\App\Resource $resource,
- \Magento\Bundle\Model\Option\Validator $validator
+ \Magento\Framework\Model\Resource\Db\Context $context,
+ \Magento\Bundle\Model\Option\Validator $validator,
+ $resourcePrefix = null
) {
- parent::__construct($resource);
+ parent::__construct($context, $resourcePrefix);
$this->validator = $validator;
}
diff --git a/app/code/Magento/Captcha/Model/Resource/Log.php b/app/code/Magento/Captcha/Model/Resource/Log.php
index 11647904b6f65..9112ee9a57ce5 100644
--- a/app/code/Magento/Captcha/Model/Resource/Log.php
+++ b/app/code/Magento/Captcha/Model/Resource/Log.php
@@ -35,18 +35,20 @@ class Log extends \Magento\Framework\Model\Resource\Db\AbstractDb
protected $_remoteAddress;
/**
- * @param \Magento\Framework\App\Resource $resource
+ * @param \Magento\Framework\Model\Resource\Db\Context $context
* @param \Magento\Framework\Stdlib\DateTime\DateTime $coreDate
* @param \Magento\Framework\HTTP\PhpEnvironment\RemoteAddress $remoteAddress
+ * @param string|null $resourcePrefix
*/
public function __construct(
- \Magento\Framework\App\Resource $resource,
+ \Magento\Framework\Model\Resource\Db\Context $context,
\Magento\Framework\Stdlib\DateTime\DateTime $coreDate,
- \Magento\Framework\HTTP\PhpEnvironment\RemoteAddress $remoteAddress
+ \Magento\Framework\HTTP\PhpEnvironment\RemoteAddress $remoteAddress,
+ $resourcePrefix = null
) {
$this->_coreDate = $coreDate;
$this->_remoteAddress = $remoteAddress;
- parent::__construct($resource);
+ parent::__construct($context, $resourcePrefix);
}
/**
diff --git a/app/code/Magento/Catalog/Model/Resource/AbstractResource.php b/app/code/Magento/Catalog/Model/Resource/AbstractResource.php
index a27766bd86276..a71d342df4803 100644
--- a/app/code/Magento/Catalog/Model/Resource/AbstractResource.php
+++ b/app/code/Magento/Catalog/Model/Resource/AbstractResource.php
@@ -38,40 +38,20 @@ abstract class AbstractResource extends \Magento\Eav\Model\Entity\AbstractEntity
protected $_modelFactory;
/**
- * Construct
- *
- * @param \Magento\Framework\App\Resource $resource
- * @param \Magento\Eav\Model\Config $eavConfig
- * @param \Magento\Eav\Model\Entity\Attribute\Set $attrSetEntity
- * @param \Magento\Framework\Locale\FormatInterface $localeFormat
- * @param \Magento\Eav\Model\Resource\Helper $resourceHelper
- * @param \Magento\Framework\Validator\UniversalFactory $universalFactory
+ * @param \Magento\Eav\Model\Entity\Context $context
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
* @param \Magento\Catalog\Model\Factory $modelFactory
* @param array $data
*/
public function __construct(
- \Magento\Framework\App\Resource $resource,
- \Magento\Eav\Model\Config $eavConfig,
- \Magento\Eav\Model\Entity\Attribute\Set $attrSetEntity,
- \Magento\Framework\Locale\FormatInterface $localeFormat,
- \Magento\Eav\Model\Resource\Helper $resourceHelper,
- \Magento\Framework\Validator\UniversalFactory $universalFactory,
+ \Magento\Eav\Model\Entity\Context $context,
\Magento\Store\Model\StoreManagerInterface $storeManager,
\Magento\Catalog\Model\Factory $modelFactory,
$data = []
) {
$this->_storeManager = $storeManager;
$this->_modelFactory = $modelFactory;
- parent::__construct(
- $resource,
- $eavConfig,
- $attrSetEntity,
- $localeFormat,
- $resourceHelper,
- $universalFactory,
- $data
- );
+ parent::__construct($context, $data);
}
/**
diff --git a/app/code/Magento/Catalog/Model/Resource/Attribute.php b/app/code/Magento/Catalog/Model/Resource/Attribute.php
index ff73a2cba5a57..31d0da053ba20 100644
--- a/app/code/Magento/Catalog/Model/Resource/Attribute.php
+++ b/app/code/Magento/Catalog/Model/Resource/Attribute.php
@@ -27,22 +27,24 @@ class Attribute extends \Magento\Eav\Model\Resource\Entity\Attribute
protected $attrLockValidator;
/**
- * @param \Magento\Framework\App\Resource $resource
+ * @param \Magento\Framework\Model\Resource\Db\Context $context
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
* @param \Magento\Eav\Model\Resource\Entity\Type $eavEntityType
* @param \Magento\Eav\Model\Config $eavConfig
* @param LockValidatorInterface $lockValidator
+ * @param string|null $resourcePrefix
*/
public function __construct(
- \Magento\Framework\App\Resource $resource,
+ \Magento\Framework\Model\Resource\Db\Context $context,
\Magento\Store\Model\StoreManagerInterface $storeManager,
\Magento\Eav\Model\Resource\Entity\Type $eavEntityType,
\Magento\Eav\Model\Config $eavConfig,
- LockValidatorInterface $lockValidator
+ LockValidatorInterface $lockValidator,
+ $resourcePrefix = null
) {
$this->attrLockValidator = $lockValidator;
$this->_eavConfig = $eavConfig;
- parent::__construct($resource, $storeManager, $eavEntityType);
+ parent::__construct($context, $storeManager, $eavEntityType, $resourcePrefix);
}
/**
diff --git a/app/code/Magento/Catalog/Model/Resource/Category.php b/app/code/Magento/Catalog/Model/Resource/Category.php
index 02a2c6d82a4d6..27e2cee709906 100644
--- a/app/code/Magento/Catalog/Model/Resource/Category.php
+++ b/app/code/Magento/Catalog/Model/Resource/Category.php
@@ -66,30 +66,16 @@ class Category extends AbstractResource
protected $_categoryTreeFactory;
/**
- * Construct
- *
- * @param \Magento\Framework\App\Resource $resource
- * @param \Magento\Eav\Model\Config $eavConfig
- * @param \Magento\Eav\Model\Entity\Attribute\Set $attrSetEntity
- * @param \Magento\Framework\Locale\FormatInterface $localeFormat
- * @param \Magento\Eav\Model\Resource\Helper $resourceHelper
- * @param \Magento\Framework\Validator\UniversalFactory $universalFactory
+ * @param \Magento\Eav\Model\Entity\Context $context
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
* @param \Magento\Catalog\Model\Factory $modelFactory
* @param \Magento\Framework\Event\ManagerInterface $eventManager
- * @param \Magento\Catalog\Model\Resource\Category\TreeFactory $categoryTreeFactory
- * @param \Magento\Catalog\Model\Resource\Category\CollectionFactory $categoryCollectionFactory
+ * @param Category\TreeFactory $categoryTreeFactory
+ * @param Category\CollectionFactory $categoryCollectionFactory
* @param array $data
- *
- * @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
public function __construct(
- \Magento\Framework\App\Resource $resource,
- \Magento\Eav\Model\Config $eavConfig,
- \Magento\Eav\Model\Entity\Attribute\Set $attrSetEntity,
- \Magento\Framework\Locale\FormatInterface $localeFormat,
- \Magento\Eav\Model\Resource\Helper $resourceHelper,
- \Magento\Framework\Validator\UniversalFactory $universalFactory,
+ \Magento\Eav\Model\Entity\Context $context,
\Magento\Store\Model\StoreManagerInterface $storeManager,
\Magento\Catalog\Model\Factory $modelFactory,
\Magento\Framework\Event\ManagerInterface $eventManager,
@@ -98,12 +84,7 @@ public function __construct(
$data = []
) {
parent::__construct(
- $resource,
- $eavConfig,
- $attrSetEntity,
- $localeFormat,
- $resourceHelper,
- $universalFactory,
+ $context,
$storeManager,
$modelFactory,
$data
diff --git a/app/code/Magento/Catalog/Model/Resource/Category/Flat.php b/app/code/Magento/Catalog/Model/Resource/Category/Flat.php
index e18f88ff4d18a..c2004dcf12292 100644
--- a/app/code/Magento/Catalog/Model/Resource/Category/Flat.php
+++ b/app/code/Magento/Catalog/Model/Resource/Category/Flat.php
@@ -78,27 +78,29 @@ class Flat extends \Magento\Indexer\Model\Resource\AbstractResource
protected $_categoryFactory;
/**
- * @param \Magento\Framework\App\Resource $resource
+ * @param \Magento\Framework\Model\Resource\Db\Context $context
* @param \Magento\Catalog\Model\CategoryFactory $categoryFactory
- * @param \Magento\Catalog\Model\Resource\Category\CollectionFactory $categoryCollectionFactory
+ * @param CollectionFactory $categoryCollectionFactory
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
* @param \Magento\Catalog\Model\Config $catalogConfig
* @param \Magento\Framework\Event\ManagerInterface $eventManager
+ * @param string|null $resourcePrefix
*/
public function __construct(
- \Magento\Framework\App\Resource $resource,
+ \Magento\Framework\Model\Resource\Db\Context $context,
\Magento\Catalog\Model\CategoryFactory $categoryFactory,
\Magento\Catalog\Model\Resource\Category\CollectionFactory $categoryCollectionFactory,
\Magento\Store\Model\StoreManagerInterface $storeManager,
\Magento\Catalog\Model\Config $catalogConfig,
- \Magento\Framework\Event\ManagerInterface $eventManager
+ \Magento\Framework\Event\ManagerInterface $eventManager,
+ $resourcePrefix = null
) {
$this->_categoryFactory = $categoryFactory;
$this->_categoryCollectionFactory = $categoryCollectionFactory;
$this->_storeManager = $storeManager;
$this->_catalogConfig = $catalogConfig;
$this->_eventManager = $eventManager;
- parent::__construct($resource);
+ parent::__construct($context, $resourcePrefix);
}
/**
diff --git a/app/code/Magento/Catalog/Model/Resource/Config.php b/app/code/Magento/Catalog/Model/Resource/Config.php
index d4abad7a0ed0c..cc8d9697c2d34 100644
--- a/app/code/Magento/Catalog/Model/Resource/Config.php
+++ b/app/code/Magento/Catalog/Model/Resource/Config.php
@@ -41,18 +41,20 @@ class Config extends \Magento\Framework\Model\Resource\Db\AbstractDb
protected $_storeManager;
/**
- * @param \Magento\Framework\App\Resource $resource
+ * @param \Magento\Framework\Model\Resource\Db\Context $context
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
* @param \Magento\Eav\Model\Config $eavConfig
+ * @param string|null $resourcePrefix
*/
public function __construct(
- \Magento\Framework\App\Resource $resource,
+ \Magento\Framework\Model\Resource\Db\Context $context,
\Magento\Store\Model\StoreManagerInterface $storeManager,
- \Magento\Eav\Model\Config $eavConfig
+ \Magento\Eav\Model\Config $eavConfig,
+ $resourcePrefix = null
) {
$this->_storeManager = $storeManager;
$this->_eavConfig = $eavConfig;
- parent::__construct($resource);
+ parent::__construct($context, $resourcePrefix);
}
/**
diff --git a/app/code/Magento/Catalog/Model/Resource/Layer/Filter/Price.php b/app/code/Magento/Catalog/Model/Resource/Layer/Filter/Price.php
index 7dfcf7810f121..e377bf69a5f9a 100644
--- a/app/code/Magento/Catalog/Model/Resource/Layer/Filter/Price.php
+++ b/app/code/Magento/Catalog/Model/Resource/Layer/Filter/Price.php
@@ -38,24 +38,26 @@ class Price extends \Magento\Framework\Model\Resource\Db\AbstractDb
private $storeManager;
/**
- * @param \Magento\Framework\App\Resource $resource
+ * @param \Magento\Framework\Model\Resource\Db\Context $context
* @param \Magento\Framework\Event\ManagerInterface $eventManager
* @param \Magento\Catalog\Model\Layer\Resolver $layerResolver
* @param \Magento\Customer\Model\Session $session
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
+ * @param string|null $resourcePrefix
*/
public function __construct(
- \Magento\Framework\App\Resource $resource,
+ \Magento\Framework\Model\Resource\Db\Context $context,
\Magento\Framework\Event\ManagerInterface $eventManager,
\Magento\Catalog\Model\Layer\Resolver $layerResolver,
\Magento\Customer\Model\Session $session,
- \Magento\Store\Model\StoreManagerInterface $storeManager
+ \Magento\Store\Model\StoreManagerInterface $storeManager,
+ $resourcePrefix = null
) {
$this->layer = $layerResolver->get();
$this->session = $session;
$this->storeManager = $storeManager;
$this->_eventManager = $eventManager;
- parent::__construct($resource);
+ parent::__construct($context, $resourcePrefix);
}
/**
diff --git a/app/code/Magento/Catalog/Model/Resource/Product.php b/app/code/Magento/Catalog/Model/Resource/Product.php
index 814f9e6ec81e9..336d8f796577e 100644
--- a/app/code/Magento/Catalog/Model/Resource/Product.php
+++ b/app/code/Magento/Catalog/Model/Resource/Product.php
@@ -57,12 +57,7 @@ class Product extends AbstractResource
protected $typeFactory;
/**
- * @param \Magento\Framework\App\Resource $resource
- * @param \Magento\Eav\Model\Config $eavConfig
- * @param \Magento\Eav\Model\Entity\Attribute\Set $attrSetEntity
- * @param \Magento\Framework\Locale\FormatInterface $localeFormat
- * @param \Magento\Eav\Model\Resource\Helper $resourceHelper
- * @param \Magento\Framework\Validator\UniversalFactory $universalFactory
+ * @param \Magento\Eav\Model\Entity\Context $context
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
* @param \Magento\Catalog\Model\Factory $modelFactory
* @param Category\CollectionFactory $categoryCollectionFactory
@@ -75,12 +70,7 @@ class Product extends AbstractResource
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
public function __construct(
- \Magento\Framework\App\Resource $resource,
- \Magento\Eav\Model\Config $eavConfig,
- \Magento\Eav\Model\Entity\Attribute\Set $attrSetEntity,
- \Magento\Framework\Locale\FormatInterface $localeFormat,
- \Magento\Eav\Model\Resource\Helper $resourceHelper,
- \Magento\Framework\Validator\UniversalFactory $universalFactory,
+ \Magento\Eav\Model\Entity\Context $context,
\Magento\Store\Model\StoreManagerInterface $storeManager,
\Magento\Catalog\Model\Factory $modelFactory,
\Magento\Catalog\Model\Resource\Category\CollectionFactory $categoryCollectionFactory,
@@ -96,12 +86,7 @@ public function __construct(
$this->setFactory = $setFactory;
$this->typeFactory = $typeFactory;
parent::__construct(
- $resource,
- $eavConfig,
- $attrSetEntity,
- $localeFormat,
- $resourceHelper,
- $universalFactory,
+ $context,
$storeManager,
$modelFactory,
$data
diff --git a/app/code/Magento/Catalog/Model/Resource/Product/Flat.php b/app/code/Magento/Catalog/Model/Resource/Product/Flat.php
index 711a988b91a94..5f80e34ea9ae4 100644
--- a/app/code/Magento/Catalog/Model/Resource/Product/Flat.php
+++ b/app/code/Magento/Catalog/Model/Resource/Product/Flat.php
@@ -36,18 +36,20 @@ class Flat extends \Magento\Framework\Model\Resource\Db\AbstractDb
protected $_storeManager;
/**
- * @param \Magento\Framework\App\Resource $resource
+ * @param \Magento\Framework\Model\Resource\Db\Context $context
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
* @param \Magento\Catalog\Model\Config $catalogConfig
+ * @param string|null $resourcePrefix
*/
public function __construct(
- \Magento\Framework\App\Resource $resource,
+ \Magento\Framework\Model\Resource\Db\Context $context,
\Magento\Store\Model\StoreManagerInterface $storeManager,
- \Magento\Catalog\Model\Config $catalogConfig
+ \Magento\Catalog\Model\Config $catalogConfig,
+ $resourcePrefix = null
) {
$this->_storeManager = $storeManager;
$this->_catalogConfig = $catalogConfig;
- parent::__construct($resource);
+ parent::__construct($context, $resourcePrefix);
}
/**
diff --git a/app/code/Magento/Catalog/Model/Resource/Product/Indexer/AbstractIndexer.php b/app/code/Magento/Catalog/Model/Resource/Product/Indexer/AbstractIndexer.php
index a360808a064a7..d8238d34208c2 100644
--- a/app/code/Magento/Catalog/Model/Resource/Product/Indexer/AbstractIndexer.php
+++ b/app/code/Magento/Catalog/Model/Resource/Product/Indexer/AbstractIndexer.php
@@ -22,13 +22,17 @@ abstract class AbstractIndexer extends \Magento\Indexer\Model\Resource\AbstractR
/**
* Class constructor
*
- * @param \Magento\Framework\App\Resource $resource
+ * @param \Magento\Framework\Model\Resource\Db\Context $context
* @param \Magento\Eav\Model\Config $eavConfig
+ * @param string|null $resourcePrefix
*/
- public function __construct(\Magento\Framework\App\Resource $resource, \Magento\Eav\Model\Config $eavConfig)
- {
+ public function __construct(
+ \Magento\Framework\Model\Resource\Db\Context $context,
+ \Magento\Eav\Model\Config $eavConfig,
+ $resourcePrefix = null
+ ) {
$this->_eavConfig = $eavConfig;
- parent::__construct($resource);
+ parent::__construct($context, $resourcePrefix);
}
/**
diff --git a/app/code/Magento/Catalog/Model/Resource/Product/Indexer/Eav/AbstractEav.php b/app/code/Magento/Catalog/Model/Resource/Product/Indexer/Eav/AbstractEav.php
index 6b407d98eb19a..8cd8d3d0e00c1 100644
--- a/app/code/Magento/Catalog/Model/Resource/Product/Indexer/Eav/AbstractEav.php
+++ b/app/code/Magento/Catalog/Model/Resource/Product/Indexer/Eav/AbstractEav.php
@@ -22,17 +22,19 @@ abstract class AbstractEav extends \Magento\Catalog\Model\Resource\Product\Index
/**
* Construct
*
- * @param \Magento\Framework\App\Resource $resource
+ * @param \Magento\Framework\Model\Resource\Db\Context $context
* @param \Magento\Eav\Model\Config $eavConfig
* @param \Magento\Framework\Event\ManagerInterface $eventManager
+ * @param string|null $resourcePrefix
*/
public function __construct(
- \Magento\Framework\App\Resource $resource,
+ \Magento\Framework\Model\Resource\Db\Context $context,
\Magento\Eav\Model\Config $eavConfig,
- \Magento\Framework\Event\ManagerInterface $eventManager
+ \Magento\Framework\Event\ManagerInterface $eventManager,
+ $resourcePrefix = null
) {
$this->_eventManager = $eventManager;
- parent::__construct($resource, $eavConfig);
+ parent::__construct($context, $eavConfig, $resourcePrefix);
}
/**
diff --git a/app/code/Magento/Catalog/Model/Resource/Product/Indexer/Eav/Source.php b/app/code/Magento/Catalog/Model/Resource/Product/Indexer/Eav/Source.php
index a6ffee370583b..844266cff0289 100644
--- a/app/code/Magento/Catalog/Model/Resource/Product/Indexer/Eav/Source.php
+++ b/app/code/Magento/Catalog/Model/Resource/Product/Indexer/Eav/Source.php
@@ -24,19 +24,21 @@ class Source extends AbstractEav
/**
* Construct
*
- * @param \Magento\Framework\App\Resource $resource
+ * @param \Magento\Framework\Model\Resource\Db\Context $context
* @param \Magento\Eav\Model\Config $eavConfig
* @param \Magento\Framework\Event\ManagerInterface $eventManager
* @param \Magento\Catalog\Model\Resource\Helper $resourceHelper
+ * @param string|null $resourcePrefix
*/
public function __construct(
- \Magento\Framework\App\Resource $resource,
+ \Magento\Framework\Model\Resource\Db\Context $context,
\Magento\Eav\Model\Config $eavConfig,
\Magento\Framework\Event\ManagerInterface $eventManager,
- \Magento\Catalog\Model\Resource\Helper $resourceHelper
+ \Magento\Catalog\Model\Resource\Helper $resourceHelper,
+ $resourcePrefix = null
) {
$this->_resourceHelper = $resourceHelper;
- parent::__construct($resource, $eavConfig, $eventManager);
+ parent::__construct($context, $eavConfig, $eventManager, $resourcePrefix);
}
/**
@@ -315,6 +317,7 @@ protected function _saveIndexData(array $data)
*
* @param string|null $table
* @return string
+ * @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function getIdxTable($table = null)
{
diff --git a/app/code/Magento/Catalog/Model/Resource/Product/Indexer/Price/DefaultPrice.php b/app/code/Magento/Catalog/Model/Resource/Product/Indexer/Price/DefaultPrice.php
index bc256d7ee3426..192f350a348df 100644
--- a/app/code/Magento/Catalog/Model/Resource/Product/Indexer/Price/DefaultPrice.php
+++ b/app/code/Magento/Catalog/Model/Resource/Product/Indexer/Price/DefaultPrice.php
@@ -42,20 +42,22 @@ class DefaultPrice extends \Magento\Catalog\Model\Resource\Product\Indexer\Abstr
protected $_eventManager = null;
/**
- * @param \Magento\Framework\App\Resource $resource
+ * @param \Magento\Framework\Model\Resource\Db\Context $context
* @param \Magento\Eav\Model\Config $eavConfig
* @param \Magento\Framework\Event\ManagerInterface $eventManager
* @param \Magento\Framework\Module\Manager $moduleManager
+ * @param string|null $resourcePrefix
*/
public function __construct(
- \Magento\Framework\App\Resource $resource,
+ \Magento\Framework\Model\Resource\Db\Context $context,
\Magento\Eav\Model\Config $eavConfig,
\Magento\Framework\Event\ManagerInterface $eventManager,
- \Magento\Framework\Module\Manager $moduleManager
+ \Magento\Framework\Module\Manager $moduleManager,
+ $resourcePrefix = null
) {
$this->_eventManager = $eventManager;
$this->moduleManager = $moduleManager;
- parent::__construct($resource, $eavConfig);
+ parent::__construct($context, $eavConfig, $resourcePrefix);
}
/**
diff --git a/app/code/Magento/Catalog/Model/Resource/Product/Link.php b/app/code/Magento/Catalog/Model/Resource/Product/Link.php
index cb70baff0420b..abe75133722f7 100644
--- a/app/code/Magento/Catalog/Model/Resource/Product/Link.php
+++ b/app/code/Magento/Catalog/Model/Resource/Product/Link.php
@@ -27,13 +27,17 @@ class Link extends \Magento\Framework\Model\Resource\Db\AbstractDb
protected $_catalogProductRelation;
/**
- * @param \Magento\Framework\App\Resource $resource
+ * @param \Magento\Framework\Model\Resource\Db\Context $context
* @param Relation $catalogProductRelation
+ * @param string|null $resourcePrefix
*/
- public function __construct(\Magento\Framework\App\Resource $resource, Relation $catalogProductRelation)
- {
+ public function __construct(
+ \Magento\Framework\Model\Resource\Db\Context $context,
+ Relation $catalogProductRelation,
+ $resourcePrefix = null
+ ) {
$this->_catalogProductRelation = $catalogProductRelation;
- parent::__construct($resource);
+ parent::__construct($context, $resourcePrefix);
}
/**
diff --git a/app/code/Magento/Catalog/Model/Resource/Product/Option.php b/app/code/Magento/Catalog/Model/Resource/Product/Option.php
index 0150acf9b0e76..27ee2f7505a24 100644
--- a/app/code/Magento/Catalog/Model/Resource/Product/Option.php
+++ b/app/code/Magento/Catalog/Model/Resource/Product/Option.php
@@ -36,21 +36,23 @@ class Option extends \Magento\Framework\Model\Resource\Db\AbstractDb
/**
* Class constructor
*
- * @param \Magento\Framework\App\Resource $resource
+ * @param \Magento\Framework\Model\Resource\Db\Context $context
* @param \Magento\Directory\Model\CurrencyFactory $currencyFactory
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
* @param \Magento\Framework\App\Config\ScopeConfigInterface $config
+ * @param string|null $resourcePrefix
*/
public function __construct(
- \Magento\Framework\App\Resource $resource,
+ \Magento\Framework\Model\Resource\Db\Context $context,
\Magento\Directory\Model\CurrencyFactory $currencyFactory,
\Magento\Store\Model\StoreManagerInterface $storeManager,
- \Magento\Framework\App\Config\ScopeConfigInterface $config
+ \Magento\Framework\App\Config\ScopeConfigInterface $config,
+ $resourcePrefix = null
) {
$this->_currencyFactory = $currencyFactory;
$this->_storeManager = $storeManager;
$this->_config = $config;
- parent::__construct($resource);
+ parent::__construct($context, $resourcePrefix);
}
/**
diff --git a/app/code/Magento/Catalog/Model/Resource/Product/Option/Value.php b/app/code/Magento/Catalog/Model/Resource/Product/Option/Value.php
index 89ecd99e7b368..d02ec14a72162 100644
--- a/app/code/Magento/Catalog/Model/Resource/Product/Option/Value.php
+++ b/app/code/Magento/Catalog/Model/Resource/Product/Option/Value.php
@@ -36,21 +36,23 @@ class Value extends \Magento\Framework\Model\Resource\Db\AbstractDb
/**
* Class constructor
*
- * @param \Magento\Framework\App\Resource $resource
+ * @param \Magento\Framework\Model\Resource\Db\Context $context
* @param \Magento\Directory\Model\CurrencyFactory $currencyFactory
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
* @param \Magento\Framework\App\Config\ScopeConfigInterface $config
+ * @param string|null $resourcePrefix
*/
public function __construct(
- \Magento\Framework\App\Resource $resource,
+ \Magento\Framework\Model\Resource\Db\Context $context,
\Magento\Directory\Model\CurrencyFactory $currencyFactory,
\Magento\Store\Model\StoreManagerInterface $storeManager,
- \Magento\Framework\App\Config\ScopeConfigInterface $config
+ \Magento\Framework\App\Config\ScopeConfigInterface $config,
+ $resourcePrefix = null
) {
$this->_currencyFactory = $currencyFactory;
$this->_storeManager = $storeManager;
$this->_config = $config;
- parent::__construct($resource);
+ parent::__construct($context, $resourcePrefix);
}
/**
diff --git a/app/code/Magento/Catalog/Model/Resource/Product/Website.php b/app/code/Magento/Catalog/Model/Resource/Product/Website.php
index 25c5a807fe892..07fafdbb92b83 100644
--- a/app/code/Magento/Catalog/Model/Resource/Product/Website.php
+++ b/app/code/Magento/Catalog/Model/Resource/Product/Website.php
@@ -18,15 +18,17 @@ class Website extends \Magento\Framework\Model\Resource\Db\AbstractDb
protected $_storeManager;
/**
- * @param \Magento\Framework\App\Resource $resource
+ * @param \Magento\Framework\Model\Resource\Db\Context $context
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
+ * @param string|null $resourcePrefix
*/
public function __construct(
- \Magento\Framework\App\Resource $resource,
- \Magento\Store\Model\StoreManagerInterface $storeManager
+ \Magento\Framework\Model\Resource\Db\Context $context,
+ \Magento\Store\Model\StoreManagerInterface $storeManager,
+ $resourcePrefix = null
) {
$this->_storeManager = $storeManager;
- parent::__construct($resource);
+ parent::__construct($context, $resourcePrefix);
}
/**
diff --git a/app/code/Magento/Catalog/Model/Resource/Url.php b/app/code/Magento/Catalog/Model/Resource/Url.php
index b41e752056677..624964013a896 100644
--- a/app/code/Magento/Catalog/Model/Resource/Url.php
+++ b/app/code/Magento/Catalog/Model/Resource/Url.php
@@ -88,27 +88,29 @@ class Url extends \Magento\Framework\Model\Resource\Db\AbstractDb
protected $productResource;
/**
- * @param \Magento\Framework\App\Resource $resource
+ * @param \Magento\Framework\Model\Resource\Db\Context $context
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
* @param \Magento\Eav\Model\Config $eavConfig
* @param Product $productResource
* @param \Magento\Catalog\Model\Category $catalogCategory
* @param \Psr\Log\LoggerInterface $logger
+ * @param string|null $resourcePrefix
*/
public function __construct(
- \Magento\Framework\App\Resource $resource,
+ \Magento\Framework\Model\Resource\Db\Context $context,
\Magento\Store\Model\StoreManagerInterface $storeManager,
\Magento\Eav\Model\Config $eavConfig,
Product $productResource,
\Magento\Catalog\Model\Category $catalogCategory,
- \Psr\Log\LoggerInterface $logger
+ \Psr\Log\LoggerInterface $logger,
+ $resourcePrefix = null
) {
$this->_storeManager = $storeManager;
$this->_eavConfig = $eavConfig;
$this->productResource = $productResource;
$this->_catalogCategory = $catalogCategory;
$this->_logger = $logger;
- parent::__construct($resource);
+ parent::__construct($context, $resourcePrefix);
}
/**
diff --git a/app/code/Magento/CatalogImportExport/Model/Import/Product.php b/app/code/Magento/CatalogImportExport/Model/Import/Product.php
index c0bac3bf821c8..692ec49b10201 100644
--- a/app/code/Magento/CatalogImportExport/Model/Import/Product.php
+++ b/app/code/Magento/CatalogImportExport/Model/Import/Product.php
@@ -10,6 +10,8 @@
use Magento\Framework\App\Filesystem\DirectoryList;
use Magento\CatalogImportExport\Model\Import\Product\RowValidatorInterface as ValidatorInterface;
+use Magento\Framework\Model\Resource\Db\TransactionManagerInterface;
+use Magento\Framework\Model\Resource\Db\ObjectRelationProcessor;
/**
* Import entity product model
@@ -373,6 +375,16 @@ class Product extends \Magento\ImportExport\Model\Import\Entity\AbstractEntity
*/
protected $masterAttributeCode = 'sku';
+ /**
+ * @var ObjectRelationProcessor
+ */
+ protected $objectRelationProcessor;
+
+ /**
+ * @var TransactionManagerInterface
+ */
+ protected $transactionManager;
+
/**
* @param \Magento\Core\Helper\Data $coreData
* @param \Magento\ImportExport\Helper\Data $importExportData
@@ -439,6 +451,8 @@ public function __construct(
Product\SkuProcessor $skuProcessor,
Product\CategoryProcessor $categoryProcessor,
Product\Validator $validator,
+ ObjectRelationProcessor $objectRelationProcessor,
+ TransactionManagerInterface $transactionManager,
array $data = []
) {
$this->_eventManager = $eventManager;
@@ -463,6 +477,8 @@ public function __construct(
$this->skuProcessor = $skuProcessor;
$this->categoryProcessor = $categoryProcessor;
$this->validator = $validator;
+ $this->objectRelationProcessor = $objectRelationProcessor;
+ $this->transactionManager = $transactionManager;
parent::__construct($coreData, $importExportData, $importData, $config, $resource, $resourceHelper, $string);
$this->_optionEntity = isset(
$data['option_entity']
@@ -504,6 +520,7 @@ public function setParameters(array $params)
* Delete products.
*
* @return $this
+ * @throws \Exception
*/
protected function _deleteProducts()
{
@@ -518,12 +535,20 @@ protected function _deleteProducts()
}
}
if ($idToDelete) {
- $this->_connection->query(
- $this->_connection->quoteInto(
- "DELETE FROM `{$productEntityTable}` WHERE `entity_id` IN (?)",
- $idToDelete
- )
- );
+ $this->transactionManager->start($this->_connection);
+ try {
+ $this->objectRelationProcessor->delete(
+ $this->transactionManager,
+ $this->_connection,
+ $productEntityTable,
+ $this->_connection->quoteInto('entity_id IN (?)', $idToDelete),
+ ['entity_id' => $idToDelete]
+ );
+ $this->transactionManager->commit();
+ } catch (\Exception $e) {
+ $this->transactionManager->rollBack();
+ throw $e;
+ }
}
}
return $this;
diff --git a/app/code/Magento/CatalogInventory/Model/Resource/Indexer/Stock/DefaultStock.php b/app/code/Magento/CatalogInventory/Model/Resource/Indexer/Stock/DefaultStock.php
index 1eb9ad27bed3b..15ae5fb50df6a 100644
--- a/app/code/Magento/CatalogInventory/Model/Resource/Indexer/Stock/DefaultStock.php
+++ b/app/code/Magento/CatalogInventory/Model/Resource/Indexer/Stock/DefaultStock.php
@@ -35,17 +35,19 @@ class DefaultStock extends \Magento\Catalog\Model\Resource\Product\Indexer\Abstr
/**
* Class constructor
*
- * @param \Magento\Framework\App\Resource $resource
+ * @param \Magento\Framework\Model\Resource\Db\Context $context
* @param \Magento\Eav\Model\Config $eavConfig
* @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
+ * @param string|null $resourcePrefix
*/
public function __construct(
- \Magento\Framework\App\Resource $resource,
+ \Magento\Framework\Model\Resource\Db\Context $context,
\Magento\Eav\Model\Config $eavConfig,
- \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
+ \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
+ $resourcePrefix = null
) {
$this->_scopeConfig = $scopeConfig;
- parent::__construct($resource, $eavConfig);
+ parent::__construct($context, $eavConfig, $resourcePrefix);
}
/**
diff --git a/app/code/Magento/CatalogInventory/Model/Resource/Stock.php b/app/code/Magento/CatalogInventory/Model/Resource/Stock.php
index 42c162eb4f8ed..45e9065928577 100644
--- a/app/code/Magento/CatalogInventory/Model/Resource/Stock.php
+++ b/app/code/Magento/CatalogInventory/Model/Resource/Stock.php
@@ -79,20 +79,22 @@ class Stock extends \Magento\Framework\Model\Resource\Db\AbstractDb
protected $storeManager;
/**
- * @param \Magento\Framework\App\Resource $resource
+ * @param \Magento\Framework\Model\Resource\Db\Context $context
* @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
* @param \Magento\Framework\Stdlib\DateTime $dateTime
* @param StockConfigurationInterface $stockConfiguration
* @param StoreManagerInterface $storeManager
+ * @param string|null $resourcePrefix
*/
public function __construct(
- \Magento\Framework\App\Resource $resource,
+ \Magento\Framework\Model\Resource\Db\Context $context,
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
\Magento\Framework\Stdlib\DateTime $dateTime,
StockConfigurationInterface $stockConfiguration,
- StoreManagerInterface $storeManager
+ StoreManagerInterface $storeManager,
+ $resourcePrefix = null
) {
- parent::__construct($resource);
+ parent::__construct($context, $resourcePrefix);
$this->_scopeConfig = $scopeConfig;
$this->dateTime = $dateTime;
$this->stockConfiguration = $stockConfiguration;
diff --git a/app/code/Magento/CatalogInventory/Model/Resource/Stock/Item.php b/app/code/Magento/CatalogInventory/Model/Resource/Stock/Item.php
index d288b95a6eae7..b182d738370fc 100644
--- a/app/code/Magento/CatalogInventory/Model/Resource/Stock/Item.php
+++ b/app/code/Magento/CatalogInventory/Model/Resource/Stock/Item.php
@@ -9,6 +9,7 @@
use Magento\CatalogInventory\Model\Indexer\Stock\Processor;
use Magento\Framework\App\Resource as AppResource;
use Magento\Framework\Model\AbstractModel;
+use Magento\Framework\Model\Resource\Db\TransactionManagerInterface;
/**
* Stock item resource model
@@ -28,15 +29,17 @@ class Item extends \Magento\Framework\Model\Resource\Db\AbstractDb
protected $stockIndexerProcessor;
/**
- * @param AppResource $resource
+ * @param \Magento\Framework\Model\Resource\Db\Context $context
* @param Processor $processor
+ * @param string|null $resourcePrefix
*/
public function __construct(
- AppResource $resource,
- Processor $processor
+ \Magento\Framework\Model\Resource\Db\Context $context,
+ Processor $processor,
+ $resourcePrefix = null
) {
$this->stockIndexerProcessor = $processor;
- parent::__construct($resource);
+ parent::__construct($context, $resourcePrefix);
}
/**
diff --git a/app/code/Magento/CatalogInventory/Model/Resource/Stock/Status.php b/app/code/Magento/CatalogInventory/Model/Resource/Stock/Status.php
index 4b971fecf3131..b3138b36b8db0 100644
--- a/app/code/Magento/CatalogInventory/Model/Resource/Stock/Status.php
+++ b/app/code/Magento/CatalogInventory/Model/Resource/Stock/Status.php
@@ -32,18 +32,20 @@ class Status extends \Magento\Framework\Model\Resource\Db\AbstractDb
protected $eavConfig;
/**
- * @param \Magento\Framework\App\Resource $resource
+ * @param \Magento\Framework\Model\Resource\Db\Context $context
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
* @param \Magento\Store\Model\WebsiteFactory $websiteFactory
* @param \Magento\Eav\Model\Config $eavConfig
+ * @param string|null $resourcePrefix
*/
public function __construct(
- \Magento\Framework\App\Resource $resource,
+ \Magento\Framework\Model\Resource\Db\Context $context,
\Magento\Store\Model\StoreManagerInterface $storeManager,
\Magento\Store\Model\WebsiteFactory $websiteFactory,
- \Magento\Eav\Model\Config $eavConfig
+ \Magento\Eav\Model\Config $eavConfig,
+ $resourcePrefix = null
) {
- parent::__construct($resource);
+ parent::__construct($context, $resourcePrefix);
$this->_storeManager = $storeManager;
$this->_websiteFactory = $websiteFactory;
diff --git a/app/code/Magento/CatalogRule/Model/Resource/Rule.php b/app/code/Magento/CatalogRule/Model/Resource/Rule.php
index 330c01f9680b2..3fe9ce0f5f877 100644
--- a/app/code/Magento/CatalogRule/Model/Resource/Rule.php
+++ b/app/code/Magento/CatalogRule/Model/Resource/Rule.php
@@ -93,7 +93,7 @@ class Rule extends \Magento\Rule\Model\Resource\AbstractResource
protected $priceCurrency;
/**
- * @param \Magento\Framework\App\Resource $resource
+ * @param \Magento\Framework\Model\Resource\Db\Context $context
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
* @param Product\ConditionFactory $conditionFactory
* @param \Magento\Framework\Stdlib\DateTime\DateTime $coreDate
@@ -103,10 +103,11 @@ class Rule extends \Magento\Rule\Model\Resource\AbstractResource
* @param \Psr\Log\LoggerInterface $logger
* @param \Magento\Framework\Stdlib\DateTime $dateTime
* @param PriceCurrencyInterface $priceCurrency
+ * @param string|null $resourcePrefix
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
public function __construct(
- \Magento\Framework\App\Resource $resource,
+ \Magento\Framework\Model\Resource\Db\Context $context,
\Magento\Store\Model\StoreManagerInterface $storeManager,
\Magento\Catalog\Model\Product\ConditionFactory $conditionFactory,
\Magento\Framework\Stdlib\DateTime\DateTime $coreDate,
@@ -115,7 +116,8 @@ public function __construct(
\Magento\CatalogRule\Helper\Data $catalogRuleData,
\Psr\Log\LoggerInterface $logger,
\Magento\Framework\Stdlib\DateTime $dateTime,
- PriceCurrencyInterface $priceCurrency
+ PriceCurrencyInterface $priceCurrency,
+ $resourcePrefix = null
) {
$this->_storeManager = $storeManager;
$this->_conditionFactory = $conditionFactory;
@@ -126,7 +128,7 @@ public function __construct(
$this->_logger = $logger;
$this->dateTime = $dateTime;
$this->priceCurrency = $priceCurrency;
- parent::__construct($resource);
+ parent::__construct($context, $resourcePrefix);
}
/**
diff --git a/app/code/Magento/CatalogSearch/Model/Resource/Advanced.php b/app/code/Magento/CatalogSearch/Model/Resource/Advanced.php
index 2cbb9e51f972c..c1978631106ef 100644
--- a/app/code/Magento/CatalogSearch/Model/Resource/Advanced.php
+++ b/app/code/Magento/CatalogSearch/Model/Resource/Advanced.php
@@ -29,18 +29,20 @@ class Advanced extends \Magento\Framework\Model\Resource\Db\AbstractDb
/**
* Construct
*
- * @param \Magento\Framework\App\Resource $resource
+ * @param \Magento\Framework\Model\Resource\Db\Context $context
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
* @param \Magento\Framework\Event\ManagerInterface $eventManager
+ * @param string|null $resourcePrefix
*/
public function __construct(
- \Magento\Framework\App\Resource $resource,
+ \Magento\Framework\Model\Resource\Db\Context $context,
\Magento\Store\Model\StoreManagerInterface $storeManager,
- \Magento\Framework\Event\ManagerInterface $eventManager
+ \Magento\Framework\Event\ManagerInterface $eventManager,
+ $resourcePrefix = null
) {
$this->_storeManager = $storeManager;
$this->_eventManager = $eventManager;
- parent::__construct($resource);
+ parent::__construct($context, $resourcePrefix);
}
/**
diff --git a/app/code/Magento/CatalogSearch/Model/Resource/Engine.php b/app/code/Magento/CatalogSearch/Model/Resource/Engine.php
index 51b4a57f60974..baab677a9c322 100644
--- a/app/code/Magento/CatalogSearch/Model/Resource/Engine.php
+++ b/app/code/Magento/CatalogSearch/Model/Resource/Engine.php
@@ -47,24 +47,26 @@ class Engine extends AbstractDb implements EngineInterface
/**
* Construct
*
- * @param \Magento\Framework\App\Resource $resource
+ * @param \Magento\Framework\Model\Resource\Db\Context $context
* @param \Magento\Catalog\Model\Product\Visibility $catalogProductVisibility
- * @param \Magento\CatalogSearch\Model\Resource\Advanced $searchResource
+ * @param Advanced $searchResource
* @param \Magento\CatalogSearch\Helper\Data $catalogSearchData
* @param \Magento\Search\Model\Resource\Helper $resourceHelper
+ * @param string|null $resourcePrefix
*/
public function __construct(
- \Magento\Framework\App\Resource $resource,
+ \Magento\Framework\Model\Resource\Db\Context $context,
\Magento\Catalog\Model\Product\Visibility $catalogProductVisibility,
\Magento\CatalogSearch\Model\Resource\Advanced $searchResource,
\Magento\CatalogSearch\Helper\Data $catalogSearchData,
- \Magento\Search\Model\Resource\Helper $resourceHelper
+ \Magento\Search\Model\Resource\Helper $resourceHelper,
+ $resourcePrefix = null
) {
$this->_catalogProductVisibility = $catalogProductVisibility;
$this->_searchResource = $searchResource;
$this->_catalogSearchData = $catalogSearchData;
$this->_resourceHelper = $resourceHelper;
- parent::__construct($resource);
+ parent::__construct($context, $resourcePrefix);
}
/**
@@ -85,6 +87,7 @@ protected function _construct()
* @param array $index
* @param string $entity 'product'|'cms'
* @return $this
+ * @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function saveEntityIndex($entityId, $storeId, $index, $entity = 'product')
{
@@ -104,6 +107,7 @@ public function saveEntityIndex($entityId, $storeId, $index, $entity = 'product'
* @param array $entityIndexes
* @param string $entity 'product'|'cms'
* @return $this
+ * @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function saveEntityIndexes($storeId, $entityIndexes, $entity = 'product')
{
@@ -187,6 +191,7 @@ public function processAttributeValue($attribute, $value)
* @param int $entityId
* @param string $entity 'product'|'cms'
* @return $this
+ * @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function cleanIndex($storeId = null, $entityId = null, $entity = 'product')
{
diff --git a/app/code/Magento/CatalogSearch/Model/Resource/Fulltext.php b/app/code/Magento/CatalogSearch/Model/Resource/Fulltext.php
index 1f47cdd3e7a60..5997b47553eb1 100644
--- a/app/code/Magento/CatalogSearch/Model/Resource/Fulltext.php
+++ b/app/code/Magento/CatalogSearch/Model/Resource/Fulltext.php
@@ -34,21 +34,23 @@ class Fulltext extends \Magento\Framework\Model\Resource\Db\AbstractDb
protected $_resourceHelper;
/**
- * @param \Magento\Framework\App\Resource $resource
+ * @param \Magento\Framework\Model\Resource\Db\Context $context
* @param \Magento\Framework\Event\ManagerInterface $eventManager
* @param \Magento\Framework\Filter\FilterManager $filter
* @param Helper $resourceHelper
+ * @param string|null $resourcePrefix
*/
public function __construct(
- \Magento\Framework\App\Resource $resource,
+ \Magento\Framework\Model\Resource\Db\Context $context,
\Magento\Framework\Event\ManagerInterface $eventManager,
\Magento\Framework\Filter\FilterManager $filter,
- \Magento\Search\Model\Resource\Helper $resourceHelper
+ \Magento\Search\Model\Resource\Helper $resourceHelper,
+ $resourcePrefix = null
) {
$this->_eventManager = $eventManager;
$this->filter = $filter;
$this->_resourceHelper = $resourceHelper;
- parent::__construct($resource);
+ parent::__construct($context, $resourcePrefix);
}
/**
diff --git a/app/code/Magento/CheckoutAgreements/Model/Resource/Agreement.php b/app/code/Magento/CheckoutAgreements/Model/Resource/Agreement.php
index 943e6738e9e67..fe2be3940d167 100644
--- a/app/code/Magento/CheckoutAgreements/Model/Resource/Agreement.php
+++ b/app/code/Magento/CheckoutAgreements/Model/Resource/Agreement.php
@@ -19,13 +19,17 @@ class Agreement extends \Magento\Framework\Model\Resource\Db\AbstractDb
protected $filterManager;
/**
- * @param \Magento\Framework\App\Resource $resource
+ * @param \Magento\Framework\Model\Resource\Db\Context $context
* @param \Magento\Framework\Filter\FilterManager $filterManager
+ * @param string|null $resourcePrefix
*/
- public function __construct(\Magento\Framework\App\Resource $resource, \Magento\Framework\Filter\FilterManager $filterManager)
- {
+ public function __construct(
+ \Magento\Framework\Model\Resource\Db\Context $context,
+ \Magento\Framework\Filter\FilterManager $filterManager,
+ $resourcePrefix = null
+ ) {
$this->filterManager = $filterManager;
- parent::__construct($resource);
+ parent::__construct($context, $resourcePrefix);
}
/**
diff --git a/app/code/Magento/Cms/Model/Resource/Block.php b/app/code/Magento/Cms/Model/Resource/Block.php
index 67fdeb1b2b5eb..2038a89d0361b 100644
--- a/app/code/Magento/Cms/Model/Resource/Block.php
+++ b/app/code/Magento/Cms/Model/Resource/Block.php
@@ -25,16 +25,18 @@ class Block extends \Magento\Framework\Model\Resource\Db\AbstractDb
/**
* Construct
*
- * @param \Magento\Framework\App\Resource $resource
+ * @param \Magento\Framework\Model\Resource\Db\Context $context
* @param \Magento\Framework\Stdlib\DateTime\DateTime $date
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
+ * @param string|null $resourcePrefix
*/
public function __construct(
- \Magento\Framework\App\Resource $resource,
+ \Magento\Framework\Model\Resource\Db\Context $context,
\Magento\Framework\Stdlib\DateTime\DateTime $date,
- \Magento\Store\Model\StoreManagerInterface $storeManager
+ \Magento\Store\Model\StoreManagerInterface $storeManager,
+ $resourcePrefix = null
) {
- parent::__construct($resource);
+ parent::__construct($context, $resourcePrefix);
$this->_storeManager = $storeManager;
$this->_date = $date;
}
diff --git a/app/code/Magento/Cms/Model/Resource/Page.php b/app/code/Magento/Cms/Model/Resource/Page.php
index d03575afb4aa4..8d080ae79d409 100644
--- a/app/code/Magento/Cms/Model/Resource/Page.php
+++ b/app/code/Magento/Cms/Model/Resource/Page.php
@@ -40,18 +40,20 @@ class Page extends \Magento\Framework\Model\Resource\Db\AbstractDb
/**
* Construct
*
- * @param \Magento\Framework\App\Resource $resource
+ * @param \Magento\Framework\Model\Resource\Db\Context $context
* @param \Magento\Framework\Stdlib\DateTime\DateTime $date
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
* @param \Magento\Framework\Stdlib\DateTime $dateTime
+ * @param string|null $resourcePrefix
*/
public function __construct(
- \Magento\Framework\App\Resource $resource,
+ \Magento\Framework\Model\Resource\Db\Context $context,
\Magento\Framework\Stdlib\DateTime\DateTime $date,
\Magento\Store\Model\StoreManagerInterface $storeManager,
- \Magento\Framework\Stdlib\DateTime $dateTime
+ \Magento\Framework\Stdlib\DateTime $dateTime,
+ $resourcePrefix = null
) {
- parent::__construct($resource);
+ parent::__construct($context, $resourcePrefix);
$this->_date = $date;
$this->_storeManager = $storeManager;
$this->dateTime = $dateTime;
diff --git a/app/code/Magento/ConfigurableProduct/Model/Resource/Product/Type/Configurable.php b/app/code/Magento/ConfigurableProduct/Model/Resource/Product/Type/Configurable.php
index aba00204d0fe1..e556661f45b1a 100644
--- a/app/code/Magento/ConfigurableProduct/Model/Resource/Product/Type/Configurable.php
+++ b/app/code/Magento/ConfigurableProduct/Model/Resource/Product/Type/Configurable.php
@@ -17,15 +17,17 @@ class Configurable extends \Magento\Framework\Model\Resource\Db\AbstractDb
protected $_catalogProductRelation;
/**
- * @param \Magento\Framework\App\Resource $resource
+ * @param \Magento\Framework\Model\Resource\Db\Context $context
* @param \Magento\Catalog\Model\Resource\Product\Relation $catalogProductRelation
+ * @param string|null $resourcePrefix
*/
public function __construct(
- \Magento\Framework\App\Resource $resource,
- \Magento\Catalog\Model\Resource\Product\Relation $catalogProductRelation
+ \Magento\Framework\Model\Resource\Db\Context $context,
+ \Magento\Catalog\Model\Resource\Product\Relation $catalogProductRelation,
+ $resourcePrefix = null
) {
$this->_catalogProductRelation = $catalogProductRelation;
- parent::__construct($resource);
+ parent::__construct($context, $resourcePrefix);
}
/**
diff --git a/app/code/Magento/ConfigurableProduct/Model/Resource/Product/Type/Configurable/Attribute.php b/app/code/Magento/ConfigurableProduct/Model/Resource/Product/Type/Configurable/Attribute.php
index 7361db789933d..6b15d9a684ff6 100644
--- a/app/code/Magento/ConfigurableProduct/Model/Resource/Product/Type/Configurable/Attribute.php
+++ b/app/code/Magento/ConfigurableProduct/Model/Resource/Product/Type/Configurable/Attribute.php
@@ -40,18 +40,20 @@ class Attribute extends \Magento\Framework\Model\Resource\Db\AbstractDb
protected $_storeManager;
/**
- * @param \Magento\Framework\App\Resource $resource
+ * @param \Magento\Framework\Model\Resource\Db\Context $context
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
* @param \Magento\Catalog\Helper\Data $catalogData
+ * @param string|null $resourcePrefix
*/
public function __construct(
- \Magento\Framework\App\Resource $resource,
+ \Magento\Framework\Model\Resource\Db\Context $context,
\Magento\Store\Model\StoreManagerInterface $storeManager,
- \Magento\Catalog\Helper\Data $catalogData
+ \Magento\Catalog\Helper\Data $catalogData,
+ $resourcePrefix = null
) {
$this->_storeManager = $storeManager;
$this->_catalogData = $catalogData;
- parent::__construct($resource);
+ parent::__construct($context, $resourcePrefix);
}
/**
diff --git a/app/code/Magento/Core/Model/Resource/File/Storage/Database.php b/app/code/Magento/Core/Model/Resource/File/Storage/Database.php
index ac9cb6e3450eb..18f707f329349 100644
--- a/app/code/Magento/Core/Model/Resource/File/Storage/Database.php
+++ b/app/code/Magento/Core/Model/Resource/File/Storage/Database.php
@@ -16,12 +16,16 @@ class Database extends \Magento\Core\Model\Resource\File\Storage\AbstractStorage
protected $_resourceHelper;
/**
- * @param \Magento\Framework\App\Resource $resource
+ * @param \Magento\Framework\Model\Resource\Db\Context $context
* @param \Magento\Framework\DB\Helper $resourceHelper
+ * @param string|null $resourcePrefix
*/
- public function __construct(\Magento\Framework\App\Resource $resource, \Magento\Framework\DB\Helper $resourceHelper)
- {
- parent::__construct($resource);
+ public function __construct(
+ \Magento\Framework\Model\Resource\Db\Context $context,
+ \Magento\Framework\DB\Helper $resourceHelper,
+ $resourcePrefix = null
+ ) {
+ parent::__construct($context, $resourcePrefix);
$this->_resourceHelper = $resourceHelper;
}
diff --git a/app/code/Magento/Customer/Model/Resource/Address.php b/app/code/Magento/Customer/Model/Resource/Address.php
index c047a54d3eeb8..3fbe59955af8a 100644
--- a/app/code/Magento/Customer/Model/Resource/Address.php
+++ b/app/code/Magento/Customer/Model/Resource/Address.php
@@ -22,38 +22,20 @@ class Address extends \Magento\Eav\Model\Entity\AbstractEntity
protected $_customerFactory;
/**
- * @param \Magento\Framework\App\Resource $resource
- * @param \Magento\Eav\Model\Config $eavConfig
- * @param \Magento\Eav\Model\Entity\Attribute\Set $attrSetEntity
- * @param \Magento\Framework\Locale\FormatInterface $localeFormat
- * @param \Magento\Eav\Model\Resource\Helper $resourceHelper
- * @param \Magento\Framework\Validator\UniversalFactory $universalFactory
+ * @param \Magento\Eav\Model\Entity\Context $context
* @param \Magento\Framework\Validator\Factory $validatorFactory
* @param \Magento\Customer\Model\CustomerFactory $customerFactory
* @param array $data
*/
public function __construct(
- \Magento\Framework\App\Resource $resource,
- \Magento\Eav\Model\Config $eavConfig,
- \Magento\Eav\Model\Entity\Attribute\Set $attrSetEntity,
- \Magento\Framework\Locale\FormatInterface $localeFormat,
- \Magento\Eav\Model\Resource\Helper $resourceHelper,
- \Magento\Framework\Validator\UniversalFactory $universalFactory,
+ \Magento\Eav\Model\Entity\Context $context,
\Magento\Framework\Validator\Factory $validatorFactory,
\Magento\Customer\Model\CustomerFactory $customerFactory,
$data = []
) {
$this->_validatorFactory = $validatorFactory;
$this->_customerFactory = $customerFactory;
- parent::__construct(
- $resource,
- $eavConfig,
- $attrSetEntity,
- $localeFormat,
- $resourceHelper,
- $universalFactory,
- $data
- );
+ parent::__construct($context, $data);
}
/**
diff --git a/app/code/Magento/Customer/Model/Resource/Customer.php b/app/code/Magento/Customer/Model/Resource/Customer.php
index 83d7b49be3ed0..9f87049ea88eb 100644
--- a/app/code/Magento/Customer/Model/Resource/Customer.php
+++ b/app/code/Magento/Customer/Model/Resource/Customer.php
@@ -32,39 +32,20 @@ class Customer extends \Magento\Eav\Model\Entity\AbstractEntity
protected $dateTime;
/**
- * @param \Magento\Framework\App\Resource $resource
- * @param \Magento\Eav\Model\Config $eavConfig
- * @param \Magento\Eav\Model\Entity\Attribute\Set $attrSetEntity
- * @param \Magento\Framework\Locale\FormatInterface $localeFormat
- * @param \Magento\Eav\Model\Resource\Helper $resourceHelper
- * @param \Magento\Framework\Validator\UniversalFactory $universalFactory
+ * @param \Magento\Eav\Model\Entity\Context $context
* @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
* @param \Magento\Framework\Validator\Factory $validatorFactory
* @param \Magento\Framework\Stdlib\DateTime $dateTime
* @param array $data
- * @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
public function __construct(
- \Magento\Framework\App\Resource $resource,
- \Magento\Eav\Model\Config $eavConfig,
- \Magento\Eav\Model\Entity\Attribute\Set $attrSetEntity,
- \Magento\Framework\Locale\FormatInterface $localeFormat,
- \Magento\Eav\Model\Resource\Helper $resourceHelper,
- \Magento\Framework\Validator\UniversalFactory $universalFactory,
+ \Magento\Eav\Model\Entity\Context $context,
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
\Magento\Framework\Validator\Factory $validatorFactory,
\Magento\Framework\Stdlib\DateTime $dateTime,
$data = []
) {
- parent::__construct(
- $resource,
- $eavConfig,
- $attrSetEntity,
- $localeFormat,
- $resourceHelper,
- $universalFactory,
- $data
- );
+ parent::__construct($context, $data);
$this->_scopeConfig = $scopeConfig;
$this->_validatorFactory = $validatorFactory;
$this->dateTime = $dateTime;
diff --git a/app/code/Magento/Customer/Model/Resource/Group.php b/app/code/Magento/Customer/Model/Resource/Group.php
index e0cb5b7748534..49b79e0fe776c 100644
--- a/app/code/Magento/Customer/Model/Resource/Group.php
+++ b/app/code/Magento/Customer/Model/Resource/Group.php
@@ -25,18 +25,20 @@ class Group extends \Magento\Framework\Model\Resource\Db\AbstractDb
protected $_customersFactory;
/**
- * @param \Magento\Framework\App\Resource $resource
+ * @param \Magento\Framework\Model\Resource\Db\Context $context
* @param \Magento\Customer\Api\GroupManagementInterface $groupManagement
* @param Customer\CollectionFactory $customersFactory
+ * @param string|null $resourcePrefix
*/
public function __construct(
- \Magento\Framework\App\Resource $resource,
+ \Magento\Framework\Model\Resource\Db\Context $context,
\Magento\Customer\Api\GroupManagementInterface $groupManagement,
- \Magento\Customer\Model\Resource\Customer\CollectionFactory $customersFactory
+ \Magento\Customer\Model\Resource\Customer\CollectionFactory $customersFactory,
+ $resourcePrefix = null
) {
$this->_groupManagement = $groupManagement;
$this->_customersFactory = $customersFactory;
- parent::__construct($resource);
+ parent::__construct($context, $resourcePrefix);
}
/**
diff --git a/app/code/Magento/Customer/Model/Resource/Visitor.php b/app/code/Magento/Customer/Model/Resource/Visitor.php
index db568a76dbe9e..639590bd07e85 100644
--- a/app/code/Magento/Customer/Model/Resource/Visitor.php
+++ b/app/code/Magento/Customer/Model/Resource/Visitor.php
@@ -23,18 +23,20 @@ class Visitor extends \Magento\Framework\Model\Resource\Db\AbstractDb
protected $dateTime;
/**
- * @param \Magento\Framework\App\Resource $resource
+ * @param \Magento\Framework\Model\Resource\Db\Context $context
* @param \Magento\Framework\Stdlib\DateTime\DateTime $date
* @param \Magento\Framework\Stdlib\DateTime $dateTime
+ * @param string|null $resourcePrefix
*/
public function __construct(
- \Magento\Framework\App\Resource $resource,
+ \Magento\Framework\Model\Resource\Db\Context $context,
\Magento\Framework\Stdlib\DateTime\DateTime $date,
- \Magento\Framework\Stdlib\DateTime $dateTime
+ \Magento\Framework\Stdlib\DateTime $dateTime,
+ $resourcePrefix = null
) {
$this->date = $date;
$this->dateTime = $dateTime;
- parent::__construct($resource);
+ parent::__construct($context, $resourcePrefix);
}
/**
diff --git a/app/code/Magento/CustomerImportExport/Model/Resource/Import/CustomerComposite/Data.php b/app/code/Magento/CustomerImportExport/Model/Resource/Import/CustomerComposite/Data.php
index 422c51e343518..fe646f8bd95f5 100644
--- a/app/code/Magento/CustomerImportExport/Model/Resource/Import/CustomerComposite/Data.php
+++ b/app/code/Magento/CustomerImportExport/Model/Resource/Import/CustomerComposite/Data.php
@@ -26,16 +26,18 @@ class Data extends \Magento\ImportExport\Model\Resource\Import\Data
/**
* Class constructor
*
- * @param \Magento\Framework\App\Resource $resource
+ * @param \Magento\Framework\Model\Resource\Db\Context $context
* @param \Magento\Core\Helper\Data $coreHelper
+ * @param string|null $resourcePrefix
* @param array $arguments
*/
public function __construct(
- \Magento\Framework\App\Resource $resource,
+ \Magento\Framework\Model\Resource\Db\Context $context,
\Magento\Core\Helper\Data $coreHelper,
+ $resourcePrefix = null,
array $arguments = []
) {
- parent::__construct($resource, $coreHelper, $arguments);
+ parent::__construct($context, $coreHelper, $resourcePrefix, $arguments);
if (isset($arguments['entity_type'])) {
$this->_entityType = $arguments['entity_type'];
diff --git a/app/code/Magento/DesignEditor/Model/Theme/Resource/Change.php b/app/code/Magento/DesignEditor/Model/Theme/Resource/Change.php
index fdec8c5f8345a..8362b4599b4df 100644
--- a/app/code/Magento/DesignEditor/Model/Theme/Resource/Change.php
+++ b/app/code/Magento/DesignEditor/Model/Theme/Resource/Change.php
@@ -16,14 +16,17 @@ class Change extends \Magento\Framework\Model\Resource\Db\AbstractDb
protected $dateTime;
/**
- * @param \Magento\Framework\App\Resource $resource
+ * @param \Magento\Framework\Model\Resource\Db\Context $context
* @param \Magento\Framework\Stdlib\DateTime $dateTime
- * @return void
+ * @param string|null $resourcePrefix
*/
- public function __construct(\Magento\Framework\App\Resource $resource, \Magento\Framework\Stdlib\DateTime $dateTime)
- {
+ public function __construct(
+ \Magento\Framework\Model\Resource\Db\Context $context,
+ \Magento\Framework\Stdlib\DateTime $dateTime,
+ $resourcePrefix = null
+ ) {
$this->dateTime = $dateTime;
- parent::__construct($resource);
+ parent::__construct($context, $resourcePrefix);
}
/**
diff --git a/app/code/Magento/Directory/Model/Resource/Region.php b/app/code/Magento/Directory/Model/Resource/Region.php
index f6d3ddeed2286..12a28ad047755 100644
--- a/app/code/Magento/Directory/Model/Resource/Region.php
+++ b/app/code/Magento/Directory/Model/Resource/Region.php
@@ -26,12 +26,16 @@ class Region extends \Magento\Framework\Model\Resource\Db\AbstractDb
protected $_localeResolver;
/**
- * @param \Magento\Framework\App\Resource $resource
+ * @param \Magento\Framework\Model\Resource\Db\Context $context
* @param \Magento\Framework\Locale\ResolverInterface $localeResolver
+ * @param string|null $resourcePrefix
*/
- public function __construct(\Magento\Framework\App\Resource $resource, \Magento\Framework\Locale\ResolverInterface $localeResolver)
- {
- parent::__construct($resource);
+ public function __construct(
+ \Magento\Framework\Model\Resource\Db\Context $context,
+ \Magento\Framework\Locale\ResolverInterface $localeResolver,
+ $resourcePrefix = null
+ ) {
+ parent::__construct($context, $resourcePrefix);
$this->_localeResolver = $localeResolver;
}
diff --git a/app/code/Magento/Downloadable/Model/Resource/Link.php b/app/code/Magento/Downloadable/Model/Resource/Link.php
index 758401cb4b2e7..09e157f36ee96 100644
--- a/app/code/Magento/Downloadable/Model/Resource/Link.php
+++ b/app/code/Magento/Downloadable/Model/Resource/Link.php
@@ -35,24 +35,26 @@ class Link extends \Magento\Framework\Model\Resource\Db\AbstractDb
protected $_storeManager;
/**
- * @param \Magento\Framework\App\Resource $resource
+ * @param \Magento\Framework\Model\Resource\Db\Context $context
* @param \Magento\Catalog\Helper\Data $catalogData
* @param \Magento\Framework\App\Config\ScopeConfigInterface $configuration
* @param \Magento\Directory\Model\CurrencyFactory $currencyFactory
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
+ * @param string|null $resourcePrefix
*/
public function __construct(
- \Magento\Framework\App\Resource $resource,
+ \Magento\Framework\Model\Resource\Db\Context $context,
\Magento\Catalog\Helper\Data $catalogData,
\Magento\Framework\App\Config\ScopeConfigInterface $configuration,
\Magento\Directory\Model\CurrencyFactory $currencyFactory,
- \Magento\Store\Model\StoreManagerInterface $storeManager
+ \Magento\Store\Model\StoreManagerInterface $storeManager,
+ $resourcePrefix = null
) {
$this->_catalogData = $catalogData;
$this->_configuration = $configuration;
$this->_currencyFactory = $currencyFactory;
$this->_storeManager = $storeManager;
- parent::__construct($resource);
+ parent::__construct($context, $resourcePrefix);
}
/**
diff --git a/app/code/Magento/Eav/Model/Entity.php b/app/code/Magento/Eav/Model/Entity.php
index 0008058ad9cda..03ac21a167d78 100644
--- a/app/code/Magento/Eav/Model/Entity.php
+++ b/app/code/Magento/Eav/Model/Entity.php
@@ -26,32 +26,12 @@ class Entity extends \Magento\Eav\Model\Entity\AbstractEntity
const DEFAULT_ENTITY_ID_FIELD = 'entity_id';
/**
- * @param \Magento\Framework\App\Resource $resource
- * @param \Magento\Eav\Model\Config $eavConfig
- * @param \Magento\Eav\Model\Entity\Attribute\Set $attrSetEntity
- * @param \Magento\Framework\Locale\FormatInterface $localeFormat
- * @param \Magento\Eav\Model\Resource\Helper $resourceHelper
- * @param \Magento\Framework\Validator\UniversalFactory $universalFactory
+ * @param Entity\Context $context
* @param array $data
*/
- public function __construct(
- \Magento\Framework\App\Resource $resource,
- \Magento\Eav\Model\Config $eavConfig,
- \Magento\Eav\Model\Entity\Attribute\Set $attrSetEntity,
- \Magento\Framework\Locale\FormatInterface $localeFormat,
- \Magento\Eav\Model\Resource\Helper $resourceHelper,
- \Magento\Framework\Validator\UniversalFactory $universalFactory,
- $data = []
- ) {
- parent::__construct(
- $resource,
- $eavConfig,
- $attrSetEntity,
- $localeFormat,
- $resourceHelper,
- $universalFactory,
- $data
- );
- $this->setConnection($resource->getConnection('eav_read'));
+ public function __construct(\Magento\Eav\Model\Entity\Context $context, $data = [])
+ {
+ parent::__construct($context, $data);
+ $this->setConnection($this->_resource->getConnection('eav_read'));
}
}
diff --git a/app/code/Magento/Eav/Model/Entity/AbstractEntity.php b/app/code/Magento/Eav/Model/Entity/AbstractEntity.php
index cae3968cfdcb8..671b7a1d7bbe1 100644
--- a/app/code/Magento/Eav/Model/Entity/AbstractEntity.php
+++ b/app/code/Magento/Eav/Model/Entity/AbstractEntity.php
@@ -15,6 +15,8 @@
use Magento\Framework\App\Config\Element;
use Magento\Framework\Model\AbstractModel;
use Magento\Eav\Exception as EavException;
+use Magento\Framework\Model\Resource\Db\ObjectRelationProcessor;
+use Magento\Framework\Model\Resource\Db\TransactionManagerInterface;
/**
* Entity/Attribute/Model - entity abstract
@@ -191,29 +193,29 @@ abstract class AbstractEntity extends \Magento\Framework\Model\Resource\Abstract
protected $_universalFactory;
/**
- * @param \Magento\Framework\App\Resource $resource
- * @param \Magento\Eav\Model\Config $eavConfig
- * @param \Magento\Eav\Model\Entity\Attribute\Set $attrSetEntity
- * @param \Magento\Framework\Locale\FormatInterface $localeFormat
- * @param \Magento\Eav\Model\Resource\Helper $resourceHelper
- * @param \Magento\Framework\Validator\UniversalFactory $universalFactory
+ * @var TransactionManagerInterface
+ */
+ protected $transactionManager;
+
+ /**
+ * @var ObjectRelationProcessor
+ */
+ protected $objectRelationProcessor;
+
+ /**
+ * @param Context $context
* @param array $data
*/
- public function __construct(
- \Magento\Framework\App\Resource $resource,
- \Magento\Eav\Model\Config $eavConfig,
- \Magento\Eav\Model\Entity\Attribute\Set $attrSetEntity,
- \Magento\Framework\Locale\FormatInterface $localeFormat,
- \Magento\Eav\Model\Resource\Helper $resourceHelper,
- \Magento\Framework\Validator\UniversalFactory $universalFactory,
- $data = []
- ) {
- $this->_eavConfig = $eavConfig;
- $this->_resource = $resource;
- $this->_attrSetEntity = $attrSetEntity;
- $this->_localeFormat = $localeFormat;
- $this->_resourceHelper = $resourceHelper;
- $this->_universalFactory = $universalFactory;
+ public function __construct(Context $context, $data = [])
+ {
+ $this->_eavConfig = $context->getEavConfig();
+ $this->_resource = $context->getResource();
+ $this->_attrSetEntity = $context->getAttributeSetEntity();
+ $this->_localeFormat = $context->getLocaleFormat();
+ $this->_resourceHelper = $context->getResourceHelper();
+ $this->_universalFactory = $context->getUniversalFactory();
+ $this->transactionManager = $context->getTransactionManager();
+ $this->objectRelationProcessor = $context->getObjectRelationProcessor();
parent::__construct();
$properties = get_object_vars($this);
foreach ($data as $key => $value) {
@@ -1180,6 +1182,8 @@ public function save(\Magento\Framework\Object $object)
$object->setParentId((int)$object->getParentId());
+ $this->objectRelationProcessor->validateDataIntegrity($this->getEntityTable(), $object->getData());
+
$this->_beforeSave($object);
$this->_processSaveData($this->_collectSaveData($object));
$this->_afterSave($object);
@@ -1714,19 +1718,24 @@ protected function getAttributeRow($entity, $object, $attribute)
public function delete($object)
{
try {
- $this->beginTransaction();
+ $connection = $this->transactionManager->start($this->_getWriteAdapter());
if (is_numeric($object)) {
$id = (int) $object;
} elseif ($object instanceof \Magento\Framework\Object) {
$object->beforeDelete();
$id = (int) $object->getId();
}
-
$this->_beforeDelete($object);
-
try {
$where = [$this->getEntityIdField() . '=?' => $id];
- $this->_getWriteAdapter()->delete($this->getEntityTable(), $where);
+ $this->objectRelationProcessor->delete(
+ $this->transactionManager,
+ $connection,
+ $this->getEntityTable(),
+ $this->_getWriteAdapter()->quoteInto($this->getEntityIdField() . '=?', $id),
+ [$this->getEntityIdField() => $id]
+ );
+
$this->loadAllAttributes($object);
foreach ($this->getAttributesByTable() as $table => $attributes) {
$this->_getWriteAdapter()->delete($table, $where);
@@ -1741,12 +1750,12 @@ public function delete($object)
$object->isDeleted(true);
$object->afterDelete();
}
- $this->commit();
+ $this->transactionManager->commit();
if ($object instanceof \Magento\Framework\Object) {
$object->afterDeleteCommit();
}
} catch (\Exception $e) {
- $this->rollBack();
+ $this->transactionManager->rollBack();
throw $e;
}
return $this;
diff --git a/app/code/Magento/Eav/Model/Entity/Context.php b/app/code/Magento/Eav/Model/Entity/Context.php
new file mode 100644
index 0000000000000..9161fc6ed4f7c
--- /dev/null
+++ b/app/code/Magento/Eav/Model/Entity/Context.php
@@ -0,0 +1,147 @@
+eavConfig = $eavConfig;
+ $this->resource = $resource;
+ $this->attributeSetEntity = $attrSetEntity;
+ $this->localeFormat = $localeFormat;
+ $this->resourceHelper = $resourceHelper;
+ $this->universalFactory = $universalFactory;
+ $this->transactionManager = $transactionManager;
+ $this->objectRelationProcessor = $objectRelationProcessor;
+ }
+
+ /**
+ * @return \Magento\Eav\Model\Config
+ */
+ public function getEavConfig()
+ {
+ return $this->eavConfig;
+ }
+
+ /**
+ * @return \Magento\Framework\App\Resource
+ */
+ public function getResource()
+ {
+ return $this->resource;
+ }
+
+ /**
+ * @return Attribute\Set
+ */
+ public function getAttributeSetEntity()
+ {
+ return $this->attributeSetEntity;
+ }
+
+ /**
+ * @return \Magento\Framework\Locale\FormatInterface
+ */
+ public function getLocaleFormat()
+ {
+ return $this->localeFormat;
+ }
+
+ /**
+ * @return \Magento\Eav\Model\Resource\Helper
+ */
+ public function getResourceHelper()
+ {
+ return $this->resourceHelper;
+ }
+
+ /**
+ * @return \Magento\Framework\Validator\UniversalFactory
+ */
+ public function getUniversalFactory()
+ {
+ return $this->universalFactory;
+ }
+
+ /**
+ * @return \Magento\Framework\Model\Resource\Db\ObjectRelationProcessor
+ */
+ public function getObjectRelationProcessor()
+ {
+ return $this->objectRelationProcessor;
+ }
+
+ /**
+ * @return \Magento\Framework\Model\Resource\Db\TransactionManagerInterface
+ */
+ public function getTransactionManager()
+ {
+ return $this->transactionManager;
+ }
+}
diff --git a/app/code/Magento/Eav/Model/Resource/Entity/Attribute.php b/app/code/Magento/Eav/Model/Resource/Entity/Attribute.php
index bfebbcb0f955a..63d60fce36f60 100644
--- a/app/code/Magento/Eav/Model/Resource/Entity/Attribute.php
+++ b/app/code/Magento/Eav/Model/Resource/Entity/Attribute.php
@@ -37,18 +37,20 @@ class Attribute extends \Magento\Framework\Model\Resource\Db\AbstractDb
/**
* Class constructor
*
- * @param \Magento\Framework\App\Resource $resource
+ * @param \Magento\Framework\Model\Resource\Db\Context $context
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
* @param Type $eavEntityType
+ * @param string|null $resourcePrefix
*/
public function __construct(
- \Magento\Framework\App\Resource $resource,
+ \Magento\Framework\Model\Resource\Db\Context $context,
\Magento\Store\Model\StoreManagerInterface $storeManager,
- Type $eavEntityType
+ Type $eavEntityType,
+ $resourcePrefix = null
) {
$this->_storeManager = $storeManager;
$this->_eavEntityType = $eavEntityType;
- parent::__construct($resource);
+ parent::__construct($context, $resourcePrefix);
}
/**
diff --git a/app/code/Magento/Eav/Model/Resource/Entity/Attribute/Set.php b/app/code/Magento/Eav/Model/Resource/Entity/Attribute/Set.php
index 7bd4b9475e6ea..2dab1d5aae67c 100644
--- a/app/code/Magento/Eav/Model/Resource/Entity/Attribute/Set.php
+++ b/app/code/Magento/Eav/Model/Resource/Entity/Attribute/Set.php
@@ -23,16 +23,18 @@ class Set extends \Magento\Framework\Model\Resource\Db\AbstractDb
protected $eavConfig;
/**
- * @param \Magento\Framework\App\Resource $resource
+ * @param \Magento\Framework\Model\Resource\Db\Context $context
* @param GroupFactory $attrGroupFactory
* @param \Magento\Eav\Model\Config $eavConfig
+ * @param string|null $resourcePrefix
*/
public function __construct(
- \Magento\Framework\App\Resource $resource,
+ \Magento\Framework\Model\Resource\Db\Context $context,
\Magento\Eav\Model\Resource\Entity\Attribute\GroupFactory $attrGroupFactory,
- \Magento\Eav\Model\Config $eavConfig
+ \Magento\Eav\Model\Config $eavConfig,
+ $resourcePrefix = null
) {
- parent::__construct($resource);
+ parent::__construct($context, $resourcePrefix);
$this->_attrGroupFactory = $attrGroupFactory;
$this->eavConfig = $eavConfig;
}
diff --git a/app/code/Magento/Email/Model/Resource/Template.php b/app/code/Magento/Email/Model/Resource/Template.php
index fdff9c6aced1f..6933b66444acb 100644
--- a/app/code/Magento/Email/Model/Resource/Template.php
+++ b/app/code/Magento/Email/Model/Resource/Template.php
@@ -20,13 +20,17 @@ class Template extends \Magento\Framework\Model\Resource\Db\AbstractDb
protected $dateTime;
/**
- * @param \Magento\Framework\App\Resource $resource
+ * @param \Magento\Framework\Model\Resource\Db\Context $context
* @param \Magento\Framework\Stdlib\DateTime $dateTime
+ * @param string|null $resourcePrefix
*/
- public function __construct(\Magento\Framework\App\Resource $resource, \Magento\Framework\Stdlib\DateTime $dateTime)
- {
+ public function __construct(
+ \Magento\Framework\Model\Resource\Db\Context $context,
+ \Magento\Framework\Stdlib\DateTime $dateTime,
+ $resourcePrefix = null
+ ) {
$this->dateTime = $dateTime;
- parent::__construct($resource);
+ parent::__construct($context, $resourcePrefix);
}
/**
diff --git a/app/code/Magento/GiftMessage/Model/Plugin/QuoteItem.php b/app/code/Magento/GiftMessage/Model/Plugin/QuoteItem.php
index bd4bbe9e1c8eb..f2538b84b6a23 100644
--- a/app/code/Magento/GiftMessage/Model/Plugin/QuoteItem.php
+++ b/app/code/Magento/GiftMessage/Model/Plugin/QuoteItem.php
@@ -35,7 +35,7 @@ public function aroundConvert(
\Magento\Quote\Model\Quote\Item\ToOrderItem $subject,
Closure $proceed,
\Magento\Quote\Model\Quote\Item\AbstractItem $item,
- $additional
+ $additional = []
) {
/** @var $orderItem Item */
$orderItem = $proceed($item, $additional);
diff --git a/app/code/Magento/ImportExport/Model/Resource/Import/Data.php b/app/code/Magento/ImportExport/Model/Resource/Import/Data.php
index 7d58963bbc705..1f0b09ee3335e 100644
--- a/app/code/Magento/ImportExport/Model/Resource/Import/Data.php
+++ b/app/code/Magento/ImportExport/Model/Resource/Import/Data.php
@@ -27,16 +27,18 @@ class Data extends \Magento\Framework\Model\Resource\Db\AbstractDb implements \I
/**
* Class constructor
*
- * @param \Magento\Framework\App\Resource $resource
+ * @param \Magento\Framework\Model\Resource\Db\Context $context
* @param \Magento\Core\Helper\Data $coreHelper
+ * @param string|null $resourcePrefix
* @param array $arguments
*/
public function __construct(
- \Magento\Framework\App\Resource $resource,
+ \Magento\Framework\Model\Resource\Db\Context $context,
\Magento\Core\Helper\Data $coreHelper,
+ $resourcePrefix = null,
array $arguments = []
) {
- parent::__construct($resource);
+ parent::__construct($context, $resourcePrefix);
$this->_jsonHelper = $coreHelper;
}
diff --git a/app/code/Magento/Integration/Model/Resource/Oauth/Consumer.php b/app/code/Magento/Integration/Model/Resource/Oauth/Consumer.php
index fa7d3be9807d8..50940c682c55f 100644
--- a/app/code/Magento/Integration/Model/Resource/Oauth/Consumer.php
+++ b/app/code/Magento/Integration/Model/Resource/Oauth/Consumer.php
@@ -13,13 +13,17 @@ class Consumer extends \Magento\Framework\Model\Resource\Db\AbstractDb
protected $_dateTime;
/**
- * @param \Magento\Framework\App\Resource $resource
+ * @param \Magento\Framework\Model\Resource\Db\Context $context
* @param \Magento\Framework\Stdlib\DateTime $dateTime
+ * @param string|null $resourcePrefix
*/
- public function __construct(\Magento\Framework\App\Resource $resource, \Magento\Framework\Stdlib\DateTime $dateTime)
- {
+ public function __construct(
+ \Magento\Framework\Model\Resource\Db\Context $context,
+ \Magento\Framework\Stdlib\DateTime $dateTime,
+ $resourcePrefix = null
+ ) {
$this->_dateTime = $dateTime;
- parent::__construct($resource);
+ parent::__construct($context, $resourcePrefix);
}
/**
diff --git a/app/code/Magento/Integration/Model/Resource/Oauth/Token.php b/app/code/Magento/Integration/Model/Resource/Oauth/Token.php
index 390aee054e8cf..edf60fcb87eb4 100644
--- a/app/code/Magento/Integration/Model/Resource/Oauth/Token.php
+++ b/app/code/Magento/Integration/Model/Resource/Oauth/Token.php
@@ -18,13 +18,17 @@ class Token extends \Magento\Framework\Model\Resource\Db\AbstractDb
protected $_dateTime;
/**
- * @param \Magento\Framework\App\Resource $resource
+ * @param \Magento\Framework\Model\Resource\Db\Context $context
* @param \Magento\Framework\Stdlib\DateTime $dateTime
+ * @param string|null $resourcePrefix
*/
- public function __construct(\Magento\Framework\App\Resource $resource, \Magento\Framework\Stdlib\DateTime $dateTime)
- {
+ public function __construct(
+ \Magento\Framework\Model\Resource\Db\Context $context,
+ \Magento\Framework\Stdlib\DateTime $dateTime,
+ $resourcePrefix = null
+ ) {
$this->_dateTime = $dateTime;
- parent::__construct($resource);
+ parent::__construct($context, $resourcePrefix);
}
/**
diff --git a/app/code/Magento/Log/Model/Resource/Log.php b/app/code/Magento/Log/Model/Resource/Log.php
index a5f9996ba4563..093f718f467d0 100644
--- a/app/code/Magento/Log/Model/Resource/Log.php
+++ b/app/code/Magento/Log/Model/Resource/Log.php
@@ -30,21 +30,23 @@ class Log extends \Magento\Framework\Model\Resource\Db\AbstractDb
protected $dateTime;
/**
- * @param \Magento\Framework\App\Resource $resource
+ * @param \Magento\Framework\Model\Resource\Db\Context $context
* @param \Magento\Framework\Stdlib\DateTime\DateTime $date
* @param \Magento\Framework\Event\ManagerInterface $eventManager
* @param \Magento\Framework\Stdlib\DateTime $dateTime
+ * @param string|null $resourcePrefix
*/
public function __construct(
- \Magento\Framework\App\Resource $resource,
+ \Magento\Framework\Model\Resource\Db\Context $context,
\Magento\Framework\Stdlib\DateTime\DateTime $date,
\Magento\Framework\Event\ManagerInterface $eventManager,
- \Magento\Framework\Stdlib\DateTime $dateTime
+ \Magento\Framework\Stdlib\DateTime $dateTime,
+ $resourcePrefix = null
) {
$this->_date = $date;
$this->_eventManager = $eventManager;
$this->dateTime = $dateTime;
- parent::__construct($resource);
+ parent::__construct($context, $resourcePrefix);
}
/**
diff --git a/app/code/Magento/Log/Model/Resource/Visitor.php b/app/code/Magento/Log/Model/Resource/Visitor.php
index c11527b8462a7..ee98b9f8ef783 100644
--- a/app/code/Magento/Log/Model/Resource/Visitor.php
+++ b/app/code/Magento/Log/Model/Resource/Visitor.php
@@ -35,21 +35,23 @@ class Visitor extends \Magento\Framework\Model\Resource\Db\AbstractDb
protected $_storeManager;
/**
- * @param \Magento\Framework\App\Resource $resource
+ * @param \Magento\Framework\Model\Resource\Db\Context $context
* @param \Magento\Framework\Stdlib\DateTime\DateTime $date
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
* @param \Magento\Framework\Stdlib\String $string
+ * @param string|null $resourcePrefix
*/
public function __construct(
- \Magento\Framework\App\Resource $resource,
+ \Magento\Framework\Model\Resource\Db\Context $context,
\Magento\Framework\Stdlib\DateTime\DateTime $date,
\Magento\Store\Model\StoreManagerInterface $storeManager,
- \Magento\Framework\Stdlib\String $string
+ \Magento\Framework\Stdlib\String $string,
+ $resourcePrefix = null
) {
$this->_date = $date;
$this->_storeManager = $storeManager;
$this->string = $string;
- parent::__construct($resource);
+ parent::__construct($context, $resourcePrefix);
}
/**
diff --git a/app/code/Magento/Log/Model/Resource/Visitor/Online.php b/app/code/Magento/Log/Model/Resource/Visitor/Online.php
index ffdfe18859e6a..5c1bca2345c90 100644
--- a/app/code/Magento/Log/Model/Resource/Visitor/Online.php
+++ b/app/code/Magento/Log/Model/Resource/Visitor/Online.php
@@ -21,13 +21,17 @@ class Online extends \Magento\Framework\Model\Resource\Db\AbstractDb
protected $_date;
/**
- * @param \Magento\Framework\App\Resource $resource
+ * @param \Magento\Framework\Model\Resource\Db\Context $context
* @param \Magento\Framework\Stdlib\DateTime\DateTime $date
+ * @param string|null $resourcePrefix
*/
- public function __construct(\Magento\Framework\App\Resource $resource, \Magento\Framework\Stdlib\DateTime\DateTime $date)
- {
+ public function __construct(
+ \Magento\Framework\Model\Resource\Db\Context $context,
+ \Magento\Framework\Stdlib\DateTime\DateTime $date,
+ $resourcePrefix = null
+ ) {
$this->_date = $date;
- parent::__construct($resource);
+ parent::__construct($context, $resourcePrefix);
}
/**
diff --git a/app/code/Magento/Newsletter/Model/Resource/Queue.php b/app/code/Magento/Newsletter/Model/Resource/Queue.php
index 9dd3be584128b..5ad59bf5ca27c 100644
--- a/app/code/Magento/Newsletter/Model/Resource/Queue.php
+++ b/app/code/Magento/Newsletter/Model/Resource/Queue.php
@@ -25,14 +25,16 @@ class Queue extends \Magento\Framework\Model\Resource\Db\AbstractDb
/**
* Construct
*
- * @param \Magento\Framework\App\Resource $resource
+ * @param \Magento\Framework\Model\Resource\Db\Context $context
* @param \Magento\Newsletter\Model\Resource\Subscriber\Collection $subscriberCollection
+ * @param string|null $resourcePrefix
*/
public function __construct(
- \Magento\Framework\App\Resource $resource,
- \Magento\Newsletter\Model\Resource\Subscriber\Collection $subscriberCollection
+ \Magento\Framework\Model\Resource\Db\Context $context,
+ \Magento\Newsletter\Model\Resource\Subscriber\Collection $subscriberCollection,
+ $resourcePrefix = null
) {
- parent::__construct($resource);
+ parent::__construct($context, $resourcePrefix);
$this->_subscriberCollection = $subscriberCollection;
}
diff --git a/app/code/Magento/Newsletter/Model/Resource/Subscriber.php b/app/code/Magento/Newsletter/Model/Resource/Subscriber.php
index aec08310f10d9..267eaae12f6f8 100644
--- a/app/code/Magento/Newsletter/Model/Resource/Subscriber.php
+++ b/app/code/Magento/Newsletter/Model/Resource/Subscriber.php
@@ -55,18 +55,20 @@ class Subscriber extends \Magento\Framework\Model\Resource\Db\AbstractDb
/**
* Construct
*
- * @param \Magento\Framework\App\Resource $resource
+ * @param \Magento\Framework\Model\Resource\Db\Context $context
* @param \Magento\Framework\Stdlib\DateTime\DateTime $date
* @param \Magento\Framework\Math\Random $mathRandom
+ * @param string|null $resourcePrefix
*/
public function __construct(
- \Magento\Framework\App\Resource $resource,
+ \Magento\Framework\Model\Resource\Db\Context $context,
\Magento\Framework\Stdlib\DateTime\DateTime $date,
- \Magento\Framework\Math\Random $mathRandom
+ \Magento\Framework\Math\Random $mathRandom,
+ $resourcePrefix = null
) {
$this->_date = $date;
$this->mathRandom = $mathRandom;
- parent::__construct($resource);
+ parent::__construct($context, $resourcePrefix);
}
/**
diff --git a/app/code/Magento/Newsletter/Model/Resource/Template.php b/app/code/Magento/Newsletter/Model/Resource/Template.php
index 10e3d7b58b853..04ee1074fe71e 100644
--- a/app/code/Magento/Newsletter/Model/Resource/Template.php
+++ b/app/code/Magento/Newsletter/Model/Resource/Template.php
@@ -23,12 +23,16 @@ class Template extends \Magento\Framework\Model\Resource\Db\AbstractDb
protected $_date;
/**
- * @param \Magento\Framework\App\Resource $resource
+ * @param \Magento\Framework\Model\Resource\Db\Context $context
* @param \Magento\Framework\Stdlib\DateTime\DateTime $date
+ * @param string|null $resourcePrefix
*/
- public function __construct(\Magento\Framework\App\Resource $resource, \Magento\Framework\Stdlib\DateTime\DateTime $date)
- {
- parent::__construct($resource);
+ public function __construct(
+ \Magento\Framework\Model\Resource\Db\Context $context,
+ \Magento\Framework\Stdlib\DateTime\DateTime $date,
+ $resourcePrefix = null
+ ) {
+ parent::__construct($context, $resourcePrefix);
$this->_date = $date;
}
diff --git a/app/code/Magento/OfflineShipping/Model/Resource/Carrier/Tablerate.php b/app/code/Magento/OfflineShipping/Model/Resource/Carrier/Tablerate.php
index 62c3a528fecd7..c505620b5ff5f 100644
--- a/app/code/Magento/OfflineShipping/Model/Resource/Carrier/Tablerate.php
+++ b/app/code/Magento/OfflineShipping/Model/Resource/Carrier/Tablerate.php
@@ -122,7 +122,7 @@ class Tablerate extends \Magento\Framework\Model\Resource\Db\AbstractDb
protected $_filesystem;
/**
- * @param \Magento\Framework\App\Resource $resource
+ * @param \Magento\Framework\Model\Resource\Db\Context $context
* @param \Psr\Log\LoggerInterface $logger
* @param \Magento\Framework\App\Config\ScopeConfigInterface $coreConfig
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
@@ -130,18 +130,20 @@ class Tablerate extends \Magento\Framework\Model\Resource\Db\AbstractDb
* @param \Magento\Directory\Model\Resource\Country\CollectionFactory $countryCollectionFactory
* @param \Magento\Directory\Model\Resource\Region\CollectionFactory $regionCollectionFactory
* @param \Magento\Framework\Filesystem $filesystem
+ * @param string|null $resourcePrefix
*/
public function __construct(
- \Magento\Framework\App\Resource $resource,
+ \Magento\Framework\Model\Resource\Db\Context $context,
\Psr\Log\LoggerInterface $logger,
\Magento\Framework\App\Config\ScopeConfigInterface $coreConfig,
\Magento\Store\Model\StoreManagerInterface $storeManager,
\Magento\OfflineShipping\Model\Carrier\Tablerate $carrierTablerate,
\Magento\Directory\Model\Resource\Country\CollectionFactory $countryCollectionFactory,
\Magento\Directory\Model\Resource\Region\CollectionFactory $regionCollectionFactory,
- \Magento\Framework\Filesystem $filesystem
+ \Magento\Framework\Filesystem $filesystem,
+ $resourcePrefix = null
) {
- parent::__construct($resource);
+ parent::__construct($context, $resourcePrefix);
$this->_coreConfig = $coreConfig;
$this->_logger = $logger;
$this->_storeManager = $storeManager;
diff --git a/app/code/Magento/Persistent/Model/Resource/Session.php b/app/code/Magento/Persistent/Model/Resource/Session.php
index 8846d52e3e048..27f865c50e330 100644
--- a/app/code/Magento/Persistent/Model/Resource/Session.php
+++ b/app/code/Magento/Persistent/Model/Resource/Session.php
@@ -27,15 +27,17 @@ class Session extends \Magento\Framework\Model\Resource\Db\AbstractDb
/**
* Class constructor
*
- * @param \Magento\Framework\App\Resource $resource
+ * @param \Magento\Framework\Model\Resource\Db\Context $context
* @param \Magento\Persistent\Model\SessionFactory $sessionFactory
+ * @param string|null $resourcePrefix
*/
public function __construct(
- \Magento\Framework\App\Resource $resource,
- \Magento\Persistent\Model\SessionFactory $sessionFactory
+ \Magento\Framework\Model\Resource\Db\Context $context,
+ \Magento\Persistent\Model\SessionFactory $sessionFactory,
+ $resourcePrefix = null
) {
$this->_sessionFactory = $sessionFactory;
- parent::__construct($resource);
+ parent::__construct($context, $resourcePrefix);
}
/**
diff --git a/app/code/Magento/ProductAlert/Model/Resource/Price.php b/app/code/Magento/ProductAlert/Model/Resource/Price.php
index 1d457c4981b8a..2c0bd0c4bf74f 100644
--- a/app/code/Magento/ProductAlert/Model/Resource/Price.php
+++ b/app/code/Magento/ProductAlert/Model/Resource/Price.php
@@ -19,13 +19,17 @@ class Price extends \Magento\ProductAlert\Model\Resource\AbstractResource
protected $_dateFactory;
/**
- * @param \Magento\Framework\App\Resource $resource
+ * @param \Magento\Framework\Model\Resource\Db\Context $context
* @param \Magento\Framework\Stdlib\DateTime\DateTimeFactory $dateFactory
+ * @param string|null $resourcePrefix
*/
- public function __construct(\Magento\Framework\App\Resource $resource, \Magento\Framework\Stdlib\DateTime\DateTimeFactory $dateFactory)
- {
+ public function __construct(
+ \Magento\Framework\Model\Resource\Db\Context $context,
+ \Magento\Framework\Stdlib\DateTime\DateTimeFactory $dateFactory,
+ $resourcePrefix = null
+ ) {
$this->_dateFactory = $dateFactory;
- parent::__construct($resource);
+ parent::__construct($context, $resourcePrefix);
}
/**
diff --git a/app/code/Magento/ProductAlert/Model/Resource/Stock.php b/app/code/Magento/ProductAlert/Model/Resource/Stock.php
index 637aaea87065d..e9a1b6491d752 100644
--- a/app/code/Magento/ProductAlert/Model/Resource/Stock.php
+++ b/app/code/Magento/ProductAlert/Model/Resource/Stock.php
@@ -19,13 +19,17 @@ class Stock extends \Magento\ProductAlert\Model\Resource\AbstractResource
protected $_dateFactory;
/**
- * @param \Magento\Framework\App\Resource $resource
+ * @param \Magento\Framework\Model\Resource\Db\Context $context
* @param \Magento\Framework\Stdlib\DateTime\DateTimeFactory $dateFactory
+ * @param string|null $resourcePrefix
*/
- public function __construct(\Magento\Framework\App\Resource $resource, \Magento\Framework\Stdlib\DateTime\DateTimeFactory $dateFactory)
- {
+ public function __construct(
+ \Magento\Framework\Model\Resource\Db\Context $context,
+ \Magento\Framework\Stdlib\DateTime\DateTimeFactory $dateFactory,
+ $resourcePrefix = null
+ ) {
$this->_dateFactory = $dateFactory;
- parent::__construct($resource);
+ parent::__construct($context, $resourcePrefix);
}
/**
diff --git a/app/code/Magento/Quote/Model/Resource/Quote.php b/app/code/Magento/Quote/Model/Resource/Quote.php
index fac8e129483c3..4483f59150e89 100644
--- a/app/code/Magento/Quote/Model/Resource/Quote.php
+++ b/app/code/Magento/Quote/Model/Resource/Quote.php
@@ -21,14 +21,16 @@ class Quote extends AbstractDb
protected $_config;
/**
- * @param \Magento\Framework\App\Resource $resource
+ * @param \Magento\Framework\Model\Resource\Db\Context $context
* @param \Magento\Eav\Model\Config $config
+ * @param string|null $resourcePrefix
*/
public function __construct(
- \Magento\Framework\App\Resource $resource,
- \Magento\Eav\Model\Config $config
+ \Magento\Framework\Model\Resource\Db\Context $context,
+ \Magento\Eav\Model\Config $config,
+ $resourcePrefix = null
) {
- parent::__construct($resource);
+ parent::__construct($context, $resourcePrefix);
$this->_config = $config;
}
diff --git a/app/code/Magento/Quote/Model/Resource/Quote/Payment.php b/app/code/Magento/Quote/Model/Resource/Quote/Payment.php
index e1ee7dc0e1aae..3275211dbf876 100644
--- a/app/code/Magento/Quote/Model/Resource/Quote/Payment.php
+++ b/app/code/Magento/Quote/Model/Resource/Quote/Payment.php
@@ -19,15 +19,6 @@ class Payment extends AbstractDb
*/
protected $_serializableFields = ['additional_information' => [null, []]];
- /**
- * @param \Magento\Framework\App\Resource $resource
- */
- public function __construct(
- \Magento\Framework\App\Resource $resource
- ) {
- parent::__construct($resource);
- }
-
/**
* Main table and field initialization
*
diff --git a/app/code/Magento/Reports/Model/Resource/Event.php b/app/code/Magento/Reports/Model/Resource/Event.php
index 313876eb8d89a..912cc7ceaa453 100644
--- a/app/code/Magento/Reports/Model/Resource/Event.php
+++ b/app/code/Magento/Reports/Model/Resource/Event.php
@@ -23,16 +23,18 @@ class Event extends \Magento\Framework\Model\Resource\Db\AbstractDb
protected $_storeManager;
/**
- * @param \Magento\Framework\App\Resource $resource
+ * @param \Magento\Framework\Model\Resource\Db\Context $context
* @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
+ * @param string|null $resourcePrefix
*/
public function __construct(
- \Magento\Framework\App\Resource $resource,
+ \Magento\Framework\Model\Resource\Db\Context $context,
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
- \Magento\Store\Model\StoreManagerInterface $storeManager
+ \Magento\Store\Model\StoreManagerInterface $storeManager,
+ $resourcePrefix = null
) {
- parent::__construct($resource);
+ parent::__construct($context, $resourcePrefix);
$this->_scopeConfig = $scopeConfig;
$this->_storeManager = $storeManager;
}
diff --git a/app/code/Magento/Reports/Model/Resource/Product/Index/AbstractIndex.php b/app/code/Magento/Reports/Model/Resource/Product/Index/AbstractIndex.php
index 9397a7272a74d..8eb599d23118d 100644
--- a/app/code/Magento/Reports/Model/Resource/Product/Index/AbstractIndex.php
+++ b/app/code/Magento/Reports/Model/Resource/Product/Index/AbstractIndex.php
@@ -24,16 +24,18 @@ abstract class AbstractIndex extends \Magento\Framework\Model\Resource\Db\Abstra
protected $_resourceHelper;
/**
- * @param \Magento\Framework\App\Resource $resource
+ * @param \Magento\Framework\Model\Resource\Db\Context $context
* @param \Magento\Reports\Model\Resource\Helper $resourceHelper
* @param \Magento\Framework\Stdlib\DateTime $dateTime
+ * @param string|null $resourcePrefix
*/
public function __construct(
- \Magento\Framework\App\Resource $resource,
+ \Magento\Framework\Model\Resource\Db\Context $context,
\Magento\Reports\Model\Resource\Helper $resourceHelper,
- \Magento\Framework\Stdlib\DateTime $dateTime
+ \Magento\Framework\Stdlib\DateTime $dateTime,
+ $resourcePrefix = null
) {
- parent::__construct($resource);
+ parent::__construct($context, $resourcePrefix);
$this->_resourceHelper = $resourceHelper;
$this->dateTime = $dateTime;
}
diff --git a/app/code/Magento/Reports/Model/Resource/Report/AbstractReport.php b/app/code/Magento/Reports/Model/Resource/Report/AbstractReport.php
index 0ffd17fd9c7db..215051833602f 100644
--- a/app/code/Magento/Reports/Model/Resource/Report/AbstractReport.php
+++ b/app/code/Magento/Reports/Model/Resource/Report/AbstractReport.php
@@ -37,22 +37,24 @@ abstract class AbstractReport extends \Magento\Framework\Model\Resource\Db\Abstr
protected $_reportsFlagFactory;
/**
- * @param \Magento\Framework\App\Resource $resource
+ * @param \Magento\Framework\Model\Resource\Db\Context $context
* @param \Psr\Log\LoggerInterface $logger
* @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate
* @param \Magento\Reports\Model\FlagFactory $reportsFlagFactory
* @param \Magento\Framework\Stdlib\DateTime $dateTime
* @param \Magento\Framework\Stdlib\DateTime\Timezone\Validator $timezoneValidator
+ * @param string|null $resourcePrefix
*/
public function __construct(
- \Magento\Framework\App\Resource $resource,
+ \Magento\Framework\Model\Resource\Db\Context $context,
\Psr\Log\LoggerInterface $logger,
\Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate,
\Magento\Reports\Model\FlagFactory $reportsFlagFactory,
\Magento\Framework\Stdlib\DateTime $dateTime,
- \Magento\Framework\Stdlib\DateTime\Timezone\Validator $timezoneValidator
+ \Magento\Framework\Stdlib\DateTime\Timezone\Validator $timezoneValidator,
+ $resourcePrefix = null
) {
- parent::__construct($resource);
+ parent::__construct($context, $resourcePrefix);
$this->_logger = $logger;
$this->_localeDate = $localeDate;
$this->_reportsFlagFactory = $reportsFlagFactory;
diff --git a/app/code/Magento/Reports/Model/Resource/Report/Product/Viewed.php b/app/code/Magento/Reports/Model/Resource/Report/Product/Viewed.php
index 4f14518968734..10e3ece5c8728 100644
--- a/app/code/Magento/Reports/Model/Resource/Report/Product/Viewed.php
+++ b/app/code/Magento/Reports/Model/Resource/Report/Product/Viewed.php
@@ -41,7 +41,7 @@ class Viewed extends \Magento\Sales\Model\Resource\Report\AbstractReport
protected $_resourceHelper;
/**
- * @param \Magento\Framework\App\Resource $resource
+ * @param \Magento\Framework\Model\Resource\Db\Context $context
* @param \Psr\Log\LoggerInterface $logger
* @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate
* @param \Magento\Reports\Model\FlagFactory $reportsFlagFactory
@@ -49,18 +49,28 @@ class Viewed extends \Magento\Sales\Model\Resource\Report\AbstractReport
* @param \Magento\Framework\Stdlib\DateTime\Timezone\Validator $timezoneValidator
* @param \Magento\Catalog\Model\Resource\Product $productResource
* @param \Magento\Reports\Model\Resource\Helper $resourceHelper
+ * @param string|null $resourcePrefix
*/
public function __construct(
- \Magento\Framework\App\Resource $resource,
+ \Magento\Framework\Model\Resource\Db\Context $context,
\Psr\Log\LoggerInterface $logger,
\Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate,
\Magento\Reports\Model\FlagFactory $reportsFlagFactory,
\Magento\Framework\Stdlib\DateTime $dateTime,
\Magento\Framework\Stdlib\DateTime\Timezone\Validator $timezoneValidator,
\Magento\Catalog\Model\Resource\Product $productResource,
- \Magento\Reports\Model\Resource\Helper $resourceHelper
+ \Magento\Reports\Model\Resource\Helper $resourceHelper,
+ $resourcePrefix = null
) {
- parent::__construct($resource, $logger, $localeDate, $reportsFlagFactory, $dateTime, $timezoneValidator);
+ parent::__construct(
+ $context,
+ $logger,
+ $localeDate,
+ $reportsFlagFactory,
+ $dateTime,
+ $timezoneValidator,
+ $resourcePrefix
+ );
$this->_productResource = $productResource;
$this->_resourceHelper = $resourceHelper;
}
diff --git a/app/code/Magento/Review/Model/Resource/Rating.php b/app/code/Magento/Review/Model/Resource/Rating.php
index 1d203bebe666b..e09fa16992692 100644
--- a/app/code/Magento/Review/Model/Resource/Rating.php
+++ b/app/code/Magento/Review/Model/Resource/Rating.php
@@ -32,24 +32,26 @@ class Rating extends \Magento\Framework\Model\Resource\Db\AbstractDb
protected $_logger;
/**
- * @param \Magento\Framework\App\Resource $resource
+ * @param \Magento\Framework\Model\Resource\Db\Context $context
* @param \Psr\Log\LoggerInterface $logger
* @param \Magento\Framework\Module\Manager $moduleManager
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
* @param \Magento\Review\Model\Resource\Review\Summary $reviewSummary
+ * @param string|null $resourcePrefix
*/
public function __construct(
- \Magento\Framework\App\Resource $resource,
+ \Magento\Framework\Model\Resource\Db\Context $context,
\Psr\Log\LoggerInterface $logger,
\Magento\Framework\Module\Manager $moduleManager,
\Magento\Store\Model\StoreManagerInterface $storeManager,
- \Magento\Review\Model\Resource\Review\Summary $reviewSummary
+ \Magento\Review\Model\Resource\Review\Summary $reviewSummary,
+ $resourcePrefix = null
) {
$this->moduleManager = $moduleManager;
$this->_storeManager = $storeManager;
$this->_logger = $logger;
$this->_reviewSummary = $reviewSummary;
- parent::__construct($resource);
+ parent::__construct($context, $resourcePrefix);
}
/**
diff --git a/app/code/Magento/Review/Model/Resource/Rating/Option.php b/app/code/Magento/Review/Model/Resource/Rating/Option.php
index 4fe3af8124772..f642e5b83e5f1 100644
--- a/app/code/Magento/Review/Model/Resource/Rating/Option.php
+++ b/app/code/Magento/Review/Model/Resource/Rating/Option.php
@@ -79,21 +79,23 @@ class Option extends \Magento\Framework\Model\Resource\Db\AbstractDb
protected $_ratingOptionVoteF;
/**
- * @param \Magento\Framework\App\Resource $resource
+ * @param \Magento\Framework\Model\Resource\Db\Context $context
* @param \Magento\Customer\Model\Session $customerSession
* @param \Magento\Review\Model\Rating\Option\VoteFactory $ratingOptionVoteF
* @param \Magento\Framework\HTTP\PhpEnvironment\RemoteAddress $remoteAddress
+ * @param string|null $resourcePrefix
*/
public function __construct(
- \Magento\Framework\App\Resource $resource,
+ \Magento\Framework\Model\Resource\Db\Context $context,
\Magento\Customer\Model\Session $customerSession,
\Magento\Review\Model\Rating\Option\VoteFactory $ratingOptionVoteF,
- \Magento\Framework\HTTP\PhpEnvironment\RemoteAddress $remoteAddress
+ \Magento\Framework\HTTP\PhpEnvironment\RemoteAddress $remoteAddress,
+ $resourcePrefix = null
) {
$this->_customerSession = $customerSession;
$this->_ratingOptionVoteF = $ratingOptionVoteF;
$this->_remoteAddress = $remoteAddress;
- parent::__construct($resource);
+ parent::__construct($context, $resourcePrefix);
}
/**
diff --git a/app/code/Magento/Review/Model/Resource/Review.php b/app/code/Magento/Review/Model/Resource/Review.php
index c6383852b817b..9ca5b4617f759 100644
--- a/app/code/Magento/Review/Model/Resource/Review.php
+++ b/app/code/Magento/Review/Model/Resource/Review.php
@@ -90,25 +90,27 @@ class Review extends \Magento\Framework\Model\Resource\Db\AbstractDb
protected $_ratingOptions;
/**
- * @param \Magento\Framework\App\Resource $resource
+ * @param \Magento\Framework\Model\Resource\Db\Context $context
* @param \Magento\Framework\Stdlib\DateTime\DateTime $date
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
* @param \Magento\Review\Model\RatingFactory $ratingFactory
* @param \Magento\Review\Model\Resource\Rating\Option $ratingOptions
+ * @param string|null $resourcePrefix
*/
public function __construct(
- \Magento\Framework\App\Resource $resource,
+ \Magento\Framework\Model\Resource\Db\Context $context,
\Magento\Framework\Stdlib\DateTime\DateTime $date,
\Magento\Store\Model\StoreManagerInterface $storeManager,
\Magento\Review\Model\RatingFactory $ratingFactory,
- Rating\Option $ratingOptions
+ Rating\Option $ratingOptions,
+ $resourcePrefix = null
) {
$this->_date = $date;
$this->_storeManager = $storeManager;
$this->_ratingFactory = $ratingFactory;
$this->_ratingOptions = $ratingOptions;
- parent::__construct($resource);
+ parent::__construct($context, $resourcePrefix);
}
/**
diff --git a/app/code/Magento/Sales/Model/Resource/AbstractGrid.php b/app/code/Magento/Sales/Model/Resource/AbstractGrid.php
index dc2952e8b17ef..ec8941c2ba11f 100644
--- a/app/code/Magento/Sales/Model/Resource/AbstractGrid.php
+++ b/app/code/Magento/Sales/Model/Resource/AbstractGrid.php
@@ -34,14 +34,6 @@ abstract class AbstractGrid extends AbstractDb implements GridInterface
*/
protected $addressTableName = 'sales_order_address';
- /**
- * @param AppResource $resource
- */
- public function __construct(AppResource $resource)
- {
- parent::__construct($resource);
- }
-
/**
* Resource initialization
*
diff --git a/app/code/Magento/Sales/Model/Resource/Entity.php b/app/code/Magento/Sales/Model/Resource/Entity.php
index 2cc6faf6f1266..ada1a586187ca 100644
--- a/app/code/Magento/Sales/Model/Resource/Entity.php
+++ b/app/code/Magento/Sales/Model/Resource/Entity.php
@@ -56,21 +56,23 @@ abstract class Entity extends AbstractDb
protected $gridAggregator;
/**
- * @param \Magento\Framework\App\Resource $resource
+ * @param \Magento\Framework\Model\Resource\Db\Context $context
* @param Attribute $attribute
* @param \Magento\Sales\Model\Increment $salesIncrement
+ * @param string|null $resourcePrefix
* @param GridInterface|null $gridAggregator
*/
public function __construct(
- \Magento\Framework\App\Resource $resource,
+ \Magento\Framework\Model\Resource\Db\Context $context,
\Magento\Sales\Model\Resource\Attribute $attribute,
\Magento\Sales\Model\Increment $salesIncrement,
+ $resourcePrefix = null,
\Magento\Sales\Model\Resource\GridInterface $gridAggregator = null
) {
$this->attribute = $attribute;
$this->salesIncrement = $salesIncrement;
$this->gridAggregator = $gridAggregator;
- parent::__construct($resource);
+ parent::__construct($context, $resourcePrefix);
}
/**
diff --git a/app/code/Magento/Sales/Model/Resource/Order.php b/app/code/Magento/Sales/Model/Resource/Order.php
index cb8a0ffa100ba..f25e34923c21c 100644
--- a/app/code/Magento/Sales/Model/Resource/Order.php
+++ b/app/code/Magento/Sales/Model/Resource/Order.php
@@ -56,24 +56,26 @@ protected function _construct()
}
/**
- * @param AppResource $resource
+ * @param \Magento\Framework\Model\Resource\Db\Context $context
* @param Attribute $attribute
* @param SalesIncrement $salesIncrement
* @param AddressHandler $addressHandler
* @param StateHandler $stateHandler
* @param OrderGrid $gridAggregator
+ * @param string|null $resourcePrefix
*/
public function __construct(
- AppResource $resource,
+ \Magento\Framework\Model\Resource\Db\Context $context,
Attribute $attribute,
SalesIncrement $salesIncrement,
AddressHandler $addressHandler,
StateHandler $stateHandler,
- OrderGrid $gridAggregator
+ OrderGrid $gridAggregator,
+ $resourcePrefix = null
) {
$this->stateHandler = $stateHandler;
$this->addressHandler = $addressHandler;
- parent::__construct($resource, $attribute, $salesIncrement, $gridAggregator);
+ parent::__construct($context, $attribute, $salesIncrement, $resourcePrefix, $gridAggregator);
}
/**
diff --git a/app/code/Magento/Sales/Model/Resource/Order/Address.php b/app/code/Magento/Sales/Model/Resource/Order/Address.php
index 7efd2e009d55d..bbe542dc5a575 100644
--- a/app/code/Magento/Sales/Model/Resource/Order/Address.php
+++ b/app/code/Magento/Sales/Model/Resource/Order/Address.php
@@ -31,24 +31,26 @@ class Address extends SalesResource implements OrderAddressResourceInterface
protected $gridPool;
/**
- * @param \Magento\Framework\App\Resource $resource
+ * @param \Magento\Framework\Model\Resource\Db\Context $context
* @param \Magento\Sales\Model\Resource\Attribute $attribute
* @param \Magento\Sales\Model\Increment $salesIncrement
* @param \Magento\Sales\Model\Order\Address\Validator $validator
* @param \Magento\Sales\Model\Resource\GridPool $gridPool
+ * @param string|null $resourcePrefix
* @param \Magento\Sales\Model\Resource\GridInterface $gridAggregator
*/
public function __construct(
- \Magento\Framework\App\Resource $resource,
+ \Magento\Framework\Model\Resource\Db\Context $context,
\Magento\Sales\Model\Resource\Attribute $attribute,
\Magento\Sales\Model\Increment $salesIncrement,
\Magento\Sales\Model\Order\Address\Validator $validator,
\Magento\Sales\Model\Resource\GridPool $gridPool,
+ $resourcePrefix = null,
\Magento\Sales\Model\Resource\GridInterface $gridAggregator = null
) {
$this->_validator = $validator;
$this->gridPool = $gridPool;
- parent::__construct($resource, $attribute, $salesIncrement, $gridAggregator);
+ parent::__construct($context, $attribute, $salesIncrement, $resourcePrefix, $gridAggregator);
}
/**
diff --git a/app/code/Magento/Sales/Model/Resource/Order/Creditmemo.php b/app/code/Magento/Sales/Model/Resource/Order/Creditmemo.php
index cc23c0550e475..11123a7771cc0 100644
--- a/app/code/Magento/Sales/Model/Resource/Order/Creditmemo.php
+++ b/app/code/Magento/Sales/Model/Resource/Order/Creditmemo.php
@@ -39,18 +39,20 @@ protected function _construct()
/**
* Constructor
*
- * @param AppResource $resource
+ * @param \Magento\Framework\Model\Resource\Db\Context $context
* @param Attribute $attribute
* @param SalesIncrement $salesIncrement
* @param CreditmemoGrid $gridAggregator
+ * @param string|null $resourcePrefix
*/
public function __construct(
- AppResource $resource,
+ \Magento\Framework\Model\Resource\Db\Context $context,
Attribute $attribute,
SalesIncrement $salesIncrement,
- CreditmemoGrid $gridAggregator
+ CreditmemoGrid $gridAggregator,
+ $resourcePrefix = null
) {
- parent::__construct($resource, $attribute, $salesIncrement, $gridAggregator);
+ parent::__construct($context, $attribute, $salesIncrement, $resourcePrefix, $gridAggregator);
}
/**
diff --git a/app/code/Magento/Sales/Model/Resource/Order/Creditmemo/Comment.php b/app/code/Magento/Sales/Model/Resource/Order/Creditmemo/Comment.php
index ee87bc1ee25af..b26ff144fb476 100644
--- a/app/code/Magento/Sales/Model/Resource/Order/Creditmemo/Comment.php
+++ b/app/code/Magento/Sales/Model/Resource/Order/Creditmemo/Comment.php
@@ -30,21 +30,23 @@ class Comment extends Entity implements CreditmemoCommentResourceInterface
protected $validator;
/**
- * @param \Magento\Framework\App\Resource $resource
+ * @param \Magento\Framework\Model\Resource\Db\Context $context
* @param \Magento\Sales\Model\Resource\Attribute $attribute
* @param \Magento\Sales\Model\Increment $salesIncrement
* @param \Magento\Sales\Model\Order\Creditmemo\Comment\Validator $validator
+ * @param string|null $resourcePrefix
* @param \Magento\Sales\Model\Resource\GridInterface $gridAggregator
*/
public function __construct(
- \Magento\Framework\App\Resource $resource,
+ \Magento\Framework\Model\Resource\Db\Context $context,
\Magento\Sales\Model\Resource\Attribute $attribute,
\Magento\Sales\Model\Increment $salesIncrement,
\Magento\Sales\Model\Order\Creditmemo\Comment\Validator $validator,
+ $resourcePrefix = null,
\Magento\Sales\Model\Resource\GridInterface $gridAggregator = null
) {
$this->validator = $validator;
- parent::__construct($resource, $attribute, $salesIncrement, $gridAggregator);
+ parent::__construct($context, $attribute, $salesIncrement, $resourcePrefix, $gridAggregator);
}
/**
diff --git a/app/code/Magento/Sales/Model/Resource/Order/Invoice.php b/app/code/Magento/Sales/Model/Resource/Order/Invoice.php
index 6daf36254290c..79317bda2843a 100644
--- a/app/code/Magento/Sales/Model/Resource/Order/Invoice.php
+++ b/app/code/Magento/Sales/Model/Resource/Order/Invoice.php
@@ -35,18 +35,20 @@ protected function _construct()
}
/**
- * @param Resource $resource
+ * @param \Magento\Framework\Model\Resource\Db\Context $context
* @param Attribute $attribute
* @param SalesIncrement $salesIncrement
* @param InvoiceGrid $gridAggregator
+ * @param string|null $resourcePrefix
*/
public function __construct(
- Resource $resource,
+ \Magento\Framework\Model\Resource\Db\Context $context,
Attribute $attribute,
SalesIncrement $salesIncrement,
- InvoiceGrid $gridAggregator
+ InvoiceGrid $gridAggregator,
+ $resourcePrefix = null
) {
- parent::__construct($resource, $attribute, $salesIncrement, $gridAggregator);
+ parent::__construct($context, $attribute, $salesIncrement, $resourcePrefix, $gridAggregator);
}
/**
diff --git a/app/code/Magento/Sales/Model/Resource/Order/Invoice/Comment.php b/app/code/Magento/Sales/Model/Resource/Order/Invoice/Comment.php
index 3fd98f7d90aa2..ebfdc76baac95 100644
--- a/app/code/Magento/Sales/Model/Resource/Order/Invoice/Comment.php
+++ b/app/code/Magento/Sales/Model/Resource/Order/Invoice/Comment.php
@@ -30,21 +30,23 @@ class Comment extends Entity implements InvoiceCommentResourceInterface
protected $validator;
/**
- * @param \Magento\Framework\App\Resource $resource
+ * @param \Magento\Framework\Model\Resource\Db\Context $context
* @param \Magento\Sales\Model\Resource\Attribute $attribute
* @param \Magento\Sales\Model\Increment $salesIncrement
* @param \Magento\Sales\Model\Order\Invoice\Comment\Validator $validator
* @param \Magento\Sales\Model\Resource\GridInterface $gridAggregator
+ * @param string|null $resourcePrefix
*/
public function __construct(
- \Magento\Framework\App\Resource $resource,
+ \Magento\Framework\Model\Resource\Db\Context $context,
\Magento\Sales\Model\Resource\Attribute $attribute,
\Magento\Sales\Model\Increment $salesIncrement,
\Magento\Sales\Model\Order\Invoice\Comment\Validator $validator,
+ $resourcePrefix = null,
\Magento\Sales\Model\Resource\GridInterface $gridAggregator = null
) {
$this->validator = $validator;
- parent::__construct($resource, $attribute, $salesIncrement, $gridAggregator);
+ parent::__construct($context, $attribute, $salesIncrement, $resourcePrefix, $gridAggregator);
}
/**
diff --git a/app/code/Magento/Sales/Model/Resource/Order/Shipment.php b/app/code/Magento/Sales/Model/Resource/Order/Shipment.php
index e0b8b4ec64358..0d2ecdf5bfced 100644
--- a/app/code/Magento/Sales/Model/Resource/Order/Shipment.php
+++ b/app/code/Magento/Sales/Model/Resource/Order/Shipment.php
@@ -44,18 +44,20 @@ protected function _construct()
}
/**
- * @param AppResource $resource
+ * @param \Magento\Framework\Model\Resource\Db\Context $context
* @param Attribute $attribute
* @param SalesIncrement $salesIncrement
* @param ShipmentGrid $gridAggregator
+ * @param string|null $resourcePrefix
*/
public function __construct(
- AppResource $resource,
+ \Magento\Framework\Model\Resource\Db\Context $context,
Attribute $attribute,
SalesIncrement $salesIncrement,
- ShipmentGrid $gridAggregator
+ ShipmentGrid $gridAggregator,
+ $resourcePrefix = null
) {
- parent::__construct($resource, $attribute, $salesIncrement, $gridAggregator);
+ parent::__construct($context, $attribute, $salesIncrement, $resourcePrefix, $gridAggregator);
}
/**
diff --git a/app/code/Magento/Sales/Model/Resource/Order/Shipment/Comment.php b/app/code/Magento/Sales/Model/Resource/Order/Shipment/Comment.php
index 3ecb6c38043d2..4ed6b5f5c48bd 100644
--- a/app/code/Magento/Sales/Model/Resource/Order/Shipment/Comment.php
+++ b/app/code/Magento/Sales/Model/Resource/Order/Shipment/Comment.php
@@ -30,21 +30,23 @@ class Comment extends Entity implements ShipmentCommentResourceInterface
protected $validator;
/**
- * @param \Magento\Framework\App\Resource $resource
+ * @param \Magento\Framework\Model\Resource\Db\Context $context
* @param \Magento\Sales\Model\Resource\Attribute $attribute
* @param \Magento\Sales\Model\Increment $salesIncrement
* @param \Magento\Sales\Model\Order\Shipment\Comment\Validator $validator
+ * @param string|null $resourcePrefix
* @param \Magento\Sales\Model\Resource\GridInterface $gridAggregator
*/
public function __construct(
- \Magento\Framework\App\Resource $resource,
+ \Magento\Framework\Model\Resource\Db\Context $context,
\Magento\Sales\Model\Resource\Attribute $attribute,
\Magento\Sales\Model\Increment $salesIncrement,
\Magento\Sales\Model\Order\Shipment\Comment\Validator $validator,
+ $resourcePrefix = null,
\Magento\Sales\Model\Resource\GridInterface $gridAggregator = null
) {
$this->validator = $validator;
- parent::__construct($resource, $attribute, $salesIncrement, $gridAggregator);
+ parent::__construct($context, $attribute, $salesIncrement, $resourcePrefix, $gridAggregator);
}
/**
diff --git a/app/code/Magento/Sales/Model/Resource/Order/Shipment/Track.php b/app/code/Magento/Sales/Model/Resource/Order/Shipment/Track.php
index 92f8ef01027bd..f578d8b127fe8 100644
--- a/app/code/Magento/Sales/Model/Resource/Order/Shipment/Track.php
+++ b/app/code/Magento/Sales/Model/Resource/Order/Shipment/Track.php
@@ -30,21 +30,23 @@ class Track extends SalesResource implements ShipmentTrackResourceInterface
protected $validator;
/**
- * @param \Magento\Framework\App\Resource $resource
+ * @param \Magento\Framework\Model\Resource\Db\Context $context
* @param \Magento\Sales\Model\Resource\Attribute $attribute
* @param \Magento\Sales\Model\Increment $salesIncrement
* @param \Magento\Sales\Model\Order\Shipment\Track\Validator $validator
+ * @param string|null $resourcePrefix
* @param \Magento\Sales\Model\Resource\GridInterface $gridAggregator
*/
public function __construct(
- \Magento\Framework\App\Resource $resource,
+ \Magento\Framework\Model\Resource\Db\Context $context,
\Magento\Sales\Model\Resource\Attribute $attribute,
\Magento\Sales\Model\Increment $salesIncrement,
\Magento\Sales\Model\Order\Shipment\Track\Validator $validator,
+ $resourcePrefix = null,
\Magento\Sales\Model\Resource\GridInterface $gridAggregator = null
) {
$this->validator = $validator;
- parent::__construct($resource, $attribute, $salesIncrement, $gridAggregator);
+ parent::__construct($context, $attribute, $salesIncrement, $resourcePrefix, $gridAggregator);
}
/**
diff --git a/app/code/Magento/Sales/Model/Resource/Order/Status.php b/app/code/Magento/Sales/Model/Resource/Order/Status.php
index 251e4cfbf1783..717b0815250f2 100644
--- a/app/code/Magento/Sales/Model/Resource/Order/Status.php
+++ b/app/code/Magento/Sales/Model/Resource/Order/Status.php
@@ -38,15 +38,17 @@ class Status extends \Magento\Framework\Model\Resource\Db\AbstractDb
/**
* Class constructor
*
- * @param \Magento\Framework\App\Resource $resource
+ * @param \Magento\Framework\Model\Resource\Db\Context $context
* @param LogWriter $logger
+ * @param string|null $resourcePrefix
*/
public function __construct(
- Resource $resource,
- LogWriter $logger
+ \Magento\Framework\Model\Resource\Db\Context $context,
+ LogWriter $logger,
+ $resourcePrefix = null
) {
$this->logger = $logger;
- parent::__construct($resource);
+ parent::__construct($context, $resourcePrefix);
}
/**
diff --git a/app/code/Magento/Sales/Model/Resource/Order/Status/History.php b/app/code/Magento/Sales/Model/Resource/Order/Status/History.php
index 1345a74ba5282..a92dea95519e0 100644
--- a/app/code/Magento/Sales/Model/Resource/Order/Status/History.php
+++ b/app/code/Magento/Sales/Model/Resource/Order/Status/History.php
@@ -22,22 +22,23 @@ class History extends Entity implements OrderStatusHistoryResourceInterface
protected $validator;
/**
- * @param \Magento\Framework\App\Resource $resource
- * @param \Magento\Framework\Stdlib\DateTime $dateTime
+ * @param \Magento\Framework\Model\Resource\Db\Context $context
* @param \Magento\Sales\Model\Resource\Attribute $attribute
* @param \Magento\Sales\Model\Increment $salesIncrement
* @param Validator $validator
+ * @param string|null $resourcePrefix
* @param \Magento\Sales\Model\Resource\GridInterface $gridAggregator
*/
public function __construct(
- \Magento\Framework\App\Resource $resource,
+ \Magento\Framework\Model\Resource\Db\Context $context,
\Magento\Sales\Model\Resource\Attribute $attribute,
\Magento\Sales\Model\Increment $salesIncrement,
Validator $validator,
+ $resourcePrefix = null,
\Magento\Sales\Model\Resource\GridInterface $gridAggregator = null
) {
$this->validator = $validator;
- parent::__construct($resource, $attribute, $salesIncrement, $gridAggregator);
+ parent::__construct($context, $attribute, $salesIncrement, $resourcePrefix, $gridAggregator);
}
/**
diff --git a/app/code/Magento/Sales/Model/Resource/Report/Bestsellers.php b/app/code/Magento/Sales/Model/Resource/Report/Bestsellers.php
index 173d376346079..0526cdde45911 100644
--- a/app/code/Magento/Sales/Model/Resource/Report/Bestsellers.php
+++ b/app/code/Magento/Sales/Model/Resource/Report/Bestsellers.php
@@ -37,7 +37,7 @@ class Bestsellers extends AbstractReport
];
/**
- * @param \Magento\Framework\App\Resource $resource
+ * @param \Magento\Framework\Model\Resource\Db\Context $context
* @param \Psr\Log\LoggerInterface $logger
* @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate
* @param \Magento\Reports\Model\FlagFactory $reportsFlagFactory
@@ -46,9 +46,11 @@ class Bestsellers extends AbstractReport
* @param \Magento\Catalog\Model\Resource\Product $productResource
* @param \Magento\Sales\Model\Resource\Helper $salesResourceHelper
* @param array $ignoredProductTypes
+ * @param string|null $resourcePrefix
+ * @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
public function __construct(
- \Magento\Framework\App\Resource $resource,
+ \Magento\Framework\Model\Resource\Db\Context $context,
\Psr\Log\LoggerInterface $logger,
\Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate,
\Magento\Reports\Model\FlagFactory $reportsFlagFactory,
@@ -56,9 +58,18 @@ public function __construct(
\Magento\Framework\Stdlib\DateTime\Timezone\Validator $timezoneValidator,
\Magento\Catalog\Model\Resource\Product $productResource,
\Magento\Sales\Model\Resource\Helper $salesResourceHelper,
+ $resourcePrefix = null,
array $ignoredProductTypes = []
) {
- parent::__construct($resource, $logger, $localeDate, $reportsFlagFactory, $dateTime, $timezoneValidator);
+ parent::__construct(
+ $context,
+ $logger,
+ $localeDate,
+ $reportsFlagFactory,
+ $dateTime,
+ $timezoneValidator,
+ $resourcePrefix
+ );
$this->_productResource = $productResource;
$this->_salesResourceHelper = $salesResourceHelper;
$this->ignoredProductTypes = array_merge($this->ignoredProductTypes, $ignoredProductTypes);
diff --git a/app/code/Magento/Sales/Model/Resource/Report/Order.php b/app/code/Magento/Sales/Model/Resource/Report/Order.php
index 50a03c50638ef..c128a2ba3794b 100644
--- a/app/code/Magento/Sales/Model/Resource/Report/Order.php
+++ b/app/code/Magento/Sales/Model/Resource/Report/Order.php
@@ -21,7 +21,7 @@ class Order extends AbstractReport
protected $_updateDatFactory;
/**
- * @param \Magento\Framework\App\Resource $resource
+ * @param \Magento\Framework\Model\Resource\Db\Context $context
* @param \Psr\Log\LoggerInterface $logger
* @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate
* @param \Magento\Reports\Model\FlagFactory $reportsFlagFactory
@@ -29,18 +29,28 @@ class Order extends AbstractReport
* @param \Magento\Framework\Stdlib\DateTime\Timezone\Validator $timezoneValidator
* @param \Magento\Sales\Model\Resource\Report\Order\CreatedatFactory $createDatFactory
* @param \Magento\Sales\Model\Resource\Report\Order\UpdatedatFactory $updateDatFactory
+ * @param string|null $resourcePrefix
*/
public function __construct(
- \Magento\Framework\App\Resource $resource,
+ \Magento\Framework\Model\Resource\Db\Context $context,
\Psr\Log\LoggerInterface $logger,
\Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate,
\Magento\Reports\Model\FlagFactory $reportsFlagFactory,
\Magento\Framework\Stdlib\DateTime $dateTime,
\Magento\Framework\Stdlib\DateTime\Timezone\Validator $timezoneValidator,
\Magento\Sales\Model\Resource\Report\Order\CreatedatFactory $createDatFactory,
- \Magento\Sales\Model\Resource\Report\Order\UpdatedatFactory $updateDatFactory
+ \Magento\Sales\Model\Resource\Report\Order\UpdatedatFactory $updateDatFactory,
+ $resourcePrefix = null
) {
- parent::__construct($resource, $logger, $localeDate, $reportsFlagFactory, $dateTime, $timezoneValidator);
+ parent::__construct(
+ $context,
+ $logger,
+ $localeDate,
+ $reportsFlagFactory,
+ $dateTime,
+ $timezoneValidator,
+ $resourcePrefix
+ );
$this->_createDatFactory = $createDatFactory;
$this->_updateDatFactory = $updateDatFactory;
}
diff --git a/app/code/Magento/SalesRule/Model/Resource/Report/Rule.php b/app/code/Magento/SalesRule/Model/Resource/Report/Rule.php
index 761804a0754e4..a9cee771e3f91 100644
--- a/app/code/Magento/SalesRule/Model/Resource/Report/Rule.php
+++ b/app/code/Magento/SalesRule/Model/Resource/Report/Rule.php
@@ -23,7 +23,7 @@ class Rule extends \Magento\Reports\Model\Resource\Report\AbstractReport
protected $_updatedatFactory;
/**
- * @param \Magento\Framework\App\Resource $resource
+ * @param \Magento\Framework\Model\Resource\Db\Context $context
* @param \Psr\Log\LoggerInterface $logger
* @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate
* @param \Magento\Reports\Model\FlagFactory $reportsFlagFactory
@@ -31,18 +31,28 @@ class Rule extends \Magento\Reports\Model\Resource\Report\AbstractReport
* @param \Magento\Framework\Stdlib\DateTime\Timezone\Validator $timezoneValidator
* @param \Magento\SalesRule\Model\Resource\Report\Rule\CreatedatFactory $createdatFactory
* @param \Magento\SalesRule\Model\Resource\Report\Rule\UpdatedatFactory $updatedatFactory
+ * @param string|null $resourcePrefix
*/
public function __construct(
- \Magento\Framework\App\Resource $resource,
+ \Magento\Framework\Model\Resource\Db\Context $context,
\Psr\Log\LoggerInterface $logger,
\Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate,
\Magento\Reports\Model\FlagFactory $reportsFlagFactory,
\Magento\Framework\Stdlib\DateTime $dateTime,
\Magento\Framework\Stdlib\DateTime\Timezone\Validator $timezoneValidator,
\Magento\SalesRule\Model\Resource\Report\Rule\CreatedatFactory $createdatFactory,
- \Magento\SalesRule\Model\Resource\Report\Rule\UpdatedatFactory $updatedatFactory
+ \Magento\SalesRule\Model\Resource\Report\Rule\UpdatedatFactory $updatedatFactory,
+ $resourcePrefix = null
) {
- parent::__construct($resource, $logger, $localeDate, $reportsFlagFactory, $dateTime, $timezoneValidator);
+ parent::__construct(
+ $context,
+ $logger,
+ $localeDate,
+ $reportsFlagFactory,
+ $dateTime,
+ $timezoneValidator,
+ $resourcePrefix
+ );
$this->_createdatFactory = $createdatFactory;
$this->_updatedatFactory = $updatedatFactory;
}
diff --git a/app/code/Magento/SalesRule/Model/Resource/Rule.php b/app/code/Magento/SalesRule/Model/Resource/Rule.php
index cfe744acdc2b4..0a9b3fbd4d43c 100644
--- a/app/code/Magento/SalesRule/Model/Resource/Rule.php
+++ b/app/code/Magento/SalesRule/Model/Resource/Rule.php
@@ -43,18 +43,20 @@ class Rule extends \Magento\Rule\Model\Resource\AbstractResource
protected $_resourceCoupon;
/**
- * @param \Magento\Framework\App\Resource $resource
+ * @param \Magento\Framework\Model\Resource\Db\Context $context
* @param \Magento\Framework\Stdlib\String $string
* @param \Magento\SalesRule\Model\Resource\Coupon $resourceCoupon
+ * @param string|null $resourcePrefix
*/
public function __construct(
- \Magento\Framework\App\Resource $resource,
+ \Magento\Framework\Model\Resource\Db\Context $context,
\Magento\Framework\Stdlib\String $string,
- \Magento\SalesRule\Model\Resource\Coupon $resourceCoupon
+ \Magento\SalesRule\Model\Resource\Coupon $resourceCoupon,
+ $resourcePrefix = null
) {
$this->string = $string;
$this->_resourceCoupon = $resourceCoupon;
- parent::__construct($resource);
+ parent::__construct($context, $resourcePrefix);
}
/**
diff --git a/app/code/Magento/Search/Model/Resource/Query.php b/app/code/Magento/Search/Model/Resource/Query.php
index b2af20520e73f..b692cb6377e99 100644
--- a/app/code/Magento/Search/Model/Resource/Query.php
+++ b/app/code/Magento/Search/Model/Resource/Query.php
@@ -31,18 +31,20 @@ class Query extends AbstractDb
protected $dateTime;
/**
- * @param \Magento\Framework\App\Resource $resource
+ * @param \Magento\Framework\Model\Resource\Db\Context $context
* @param \Magento\Framework\Stdlib\DateTime\DateTime $date
* @param \Magento\Framework\Stdlib\DateTime $dateTime
+ * @param string|null $resourcePrefix
*/
public function __construct(
- \Magento\Framework\App\Resource $resource,
+ \Magento\Framework\Model\Resource\Db\Context $context,
\Magento\Framework\Stdlib\DateTime\DateTime $date,
- \Magento\Framework\Stdlib\DateTime $dateTime
+ \Magento\Framework\Stdlib\DateTime $dateTime,
+ $resourcePrefix = null
) {
$this->_date = $date;
$this->dateTime = $dateTime;
- parent::__construct($resource);
+ parent::__construct($context, $resourcePrefix);
}
/**
diff --git a/app/code/Magento/Sitemap/Model/Resource/Catalog/Category.php b/app/code/Magento/Sitemap/Model/Resource/Catalog/Category.php
index acb50839e3132..3dacd9647d81d 100644
--- a/app/code/Magento/Sitemap/Model/Resource/Catalog/Category.php
+++ b/app/code/Magento/Sitemap/Model/Resource/Catalog/Category.php
@@ -39,18 +39,20 @@ class Category extends \Magento\Framework\Model\Resource\Db\AbstractDb
protected $_categoryResource;
/**
- * @param \Magento\Framework\App\Resource $resource
+ * @param \Magento\Framework\Model\Resource\Db\Context $context
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
* @param \Magento\Catalog\Model\Resource\Category $categoryResource
+ * @param string|null $resourcePrefix
*/
public function __construct(
- \Magento\Framework\App\Resource $resource,
+ \Magento\Framework\Model\Resource\Db\Context $context,
\Magento\Store\Model\StoreManagerInterface $storeManager,
- \Magento\Catalog\Model\Resource\Category $categoryResource
+ \Magento\Catalog\Model\Resource\Category $categoryResource,
+ $resourcePrefix = null
) {
$this->_storeManager = $storeManager;
$this->_categoryResource = $categoryResource;
- parent::__construct($resource);
+ parent::__construct($context, $resourcePrefix);
}
/**
diff --git a/app/code/Magento/Sitemap/Model/Resource/Catalog/Product.php b/app/code/Magento/Sitemap/Model/Resource/Catalog/Product.php
index bd3741d3f5f41..8007038bc8aff 100644
--- a/app/code/Magento/Sitemap/Model/Resource/Catalog/Product.php
+++ b/app/code/Magento/Sitemap/Model/Resource/Catalog/Product.php
@@ -83,7 +83,7 @@ class Product extends \Magento\Framework\Model\Resource\Db\AbstractDb
protected $_mediaConfig;
/**
- * @param \Magento\Framework\App\Resource $resource
+ * @param \Magento\Framework\Model\Resource\Db\Context $context
* @param \Magento\Sitemap\Helper\Data $sitemapData
* @param \Magento\Catalog\Model\Resource\Product $productResource
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
@@ -92,9 +92,11 @@ class Product extends \Magento\Framework\Model\Resource\Db\AbstractDb
* @param \Magento\Catalog\Model\Resource\Product\Attribute\Backend\Media $mediaAttribute
* @param \Magento\Eav\Model\ConfigFactory $eavConfigFactory
* @param \Magento\Catalog\Model\Product\Media\Config $mediaConfig
+ * @param string|null $resourcePrefix
+ * @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
public function __construct(
- \Magento\Framework\App\Resource $resource,
+ \Magento\Framework\Model\Resource\Db\Context $context,
\Magento\Sitemap\Helper\Data $sitemapData,
\Magento\Catalog\Model\Resource\Product $productResource,
\Magento\Store\Model\StoreManagerInterface $storeManager,
@@ -102,7 +104,8 @@ public function __construct(
\Magento\Catalog\Model\Product\Attribute\Source\Status $productStatus,
\Magento\Catalog\Model\Resource\Product\Attribute\Backend\Media $mediaAttribute,
\Magento\Eav\Model\ConfigFactory $eavConfigFactory,
- \Magento\Catalog\Model\Product\Media\Config $mediaConfig
+ \Magento\Catalog\Model\Product\Media\Config $mediaConfig,
+ $resourcePrefix = null
) {
$this->_productResource = $productResource;
$this->_storeManager = $storeManager;
@@ -112,7 +115,7 @@ public function __construct(
$this->_eavConfigFactory = $eavConfigFactory;
$this->_mediaConfig = $mediaConfig;
$this->_sitemapData = $sitemapData;
- parent::__construct($resource);
+ parent::__construct($context, $resourcePrefix);
}
/**
diff --git a/app/code/Magento/Tax/Model/Resource/Calculation.php b/app/code/Magento/Tax/Model/Resource/Calculation.php
index 160bea26fe1f9..455cb33e36aa3 100644
--- a/app/code/Magento/Tax/Model/Resource/Calculation.php
+++ b/app/code/Magento/Tax/Model/Resource/Calculation.php
@@ -44,18 +44,20 @@ class Calculation extends \Magento\Framework\Model\Resource\Db\AbstractDb
protected $_storeManager;
/**
- * @param \Magento\Framework\App\Resource $resource
+ * @param \Magento\Framework\Model\Resource\Db\Context $context
* @param \Magento\Tax\Helper\Data $taxData
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
+ * @param string|null $resourcePrefix
*/
public function __construct(
- \Magento\Framework\App\Resource $resource,
+ \Magento\Framework\Model\Resource\Db\Context $context,
\Magento\Tax\Helper\Data $taxData,
- \Magento\Store\Model\StoreManagerInterface $storeManager
+ \Magento\Store\Model\StoreManagerInterface $storeManager,
+ $resourcePrefix = null
) {
$this->_taxData = $taxData;
$this->_storeManager = $storeManager;
- parent::__construct($resource);
+ parent::__construct($context, $resourcePrefix);
}
/**
diff --git a/app/code/Magento/Tax/Model/Resource/Report/Tax.php b/app/code/Magento/Tax/Model/Resource/Report/Tax.php
index 7b0e847ff4ea0..2965d505b3d2a 100644
--- a/app/code/Magento/Tax/Model/Resource/Report/Tax.php
+++ b/app/code/Magento/Tax/Model/Resource/Report/Tax.php
@@ -22,7 +22,7 @@ class Tax extends \Magento\Reports\Model\Resource\Report\AbstractReport
protected $_updatedAtFactory;
/**
- * @param \Magento\Framework\App\Resource $resource
+ * @param \Magento\Framework\Model\Resource\Db\Context $context
* @param \Psr\Log\LoggerInterface $logger
* @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate
* @param \Magento\Reports\Model\FlagFactory $reportsFlagFactory
@@ -30,20 +30,30 @@ class Tax extends \Magento\Reports\Model\Resource\Report\AbstractReport
* @param \Magento\Framework\Stdlib\DateTime\Timezone\Validator $timezoneValidator
* @param \Magento\Tax\Model\Resource\Report\Tax\CreatedatFactory $createdAtFactory
* @param \Magento\Tax\Model\Resource\Report\Tax\UpdatedatFactory $updatedAtFactory
+ * @param string|null $resourcePrefix
*/
public function __construct(
- \Magento\Framework\App\Resource $resource,
+ \Magento\Framework\Model\Resource\Db\Context $context,
\Psr\Log\LoggerInterface $logger,
\Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate,
\Magento\Reports\Model\FlagFactory $reportsFlagFactory,
\Magento\Framework\Stdlib\DateTime $dateTime,
\Magento\Framework\Stdlib\DateTime\Timezone\Validator $timezoneValidator,
\Magento\Tax\Model\Resource\Report\Tax\CreatedatFactory $createdAtFactory,
- \Magento\Tax\Model\Resource\Report\Tax\UpdatedatFactory $updatedAtFactory
+ \Magento\Tax\Model\Resource\Report\Tax\UpdatedatFactory $updatedAtFactory,
+ $resourcePrefix = null
) {
$this->_createdAtFactory = $createdAtFactory;
$this->_updatedAtFactory = $updatedAtFactory;
- parent::__construct($resource, $logger, $localeDate, $reportsFlagFactory, $dateTime, $timezoneValidator);
+ parent::__construct(
+ $context,
+ $logger,
+ $localeDate,
+ $reportsFlagFactory,
+ $dateTime,
+ $timezoneValidator,
+ $resourcePrefix
+ );
}
/**
diff --git a/app/code/Magento/Theme/Model/Resource/Design.php b/app/code/Magento/Theme/Model/Resource/Design.php
index 7d68b6089f982..4364a24c8eec8 100644
--- a/app/code/Magento/Theme/Model/Resource/Design.php
+++ b/app/code/Magento/Theme/Model/Resource/Design.php
@@ -22,13 +22,17 @@ class Design extends \Magento\Framework\Model\Resource\Db\AbstractDb
protected $dateTime;
/**
- * @param \Magento\Framework\App\Resource $resource
+ * @param \Magento\Framework\Model\Resource\Db\Context $context
* @param DateTime $dateTime
+ * @param string|null $resourcePrefix
*/
- public function __construct(\Magento\Framework\App\Resource $resource, DateTime $dateTime)
- {
+ public function __construct(
+ \Magento\Framework\Model\Resource\Db\Context $context,
+ DateTime $dateTime,
+ $resourcePrefix = null
+ ) {
$this->dateTime = $dateTime;
- parent::__construct($resource);
+ parent::__construct($context, $resourcePrefix);
}
/**
diff --git a/app/code/Magento/Translation/Model/Resource/String.php b/app/code/Magento/Translation/Model/Resource/String.php
index c620c322528f2..d33c95badef8e 100644
--- a/app/code/Magento/Translation/Model/Resource/String.php
+++ b/app/code/Magento/Translation/Model/Resource/String.php
@@ -23,21 +23,23 @@ class String extends \Magento\Framework\Model\Resource\Db\AbstractDb
protected $scope;
/**
- * @param \Magento\Framework\App\Resource $resource
+ * @param \Magento\Framework\Model\Resource\Db\Context $context
* @param \Magento\Framework\Locale\ResolverInterface $localeResolver
* @param \Magento\Framework\App\ScopeResolverInterface $scopeResolver
+ * @param string|null $resourcePrefix
* @param string|null $scope
*/
public function __construct(
- \Magento\Framework\App\Resource $resource,
+ \Magento\Framework\Model\Resource\Db\Context $context,
\Magento\Framework\Locale\ResolverInterface $localeResolver,
\Magento\Framework\App\ScopeResolverInterface $scopeResolver,
+ $resourcePrefix = null,
$scope = null
) {
$this->_localeResolver = $localeResolver;
$this->scopeResolver = $scopeResolver;
$this->scope = $scope;
- parent::__construct($resource);
+ parent::__construct($context, $resourcePrefix);
}
/**
diff --git a/app/code/Magento/Translation/Model/Resource/Translate.php b/app/code/Magento/Translation/Model/Resource/Translate.php
index b670825e370ba..873e071829ad9 100644
--- a/app/code/Magento/Translation/Model/Resource/Translate.php
+++ b/app/code/Magento/Translation/Model/Resource/Translate.php
@@ -19,18 +19,20 @@ class Translate extends \Magento\Framework\Model\Resource\Db\AbstractDb implemen
protected $scope;
/**
- * @param \Magento\Framework\App\Resource $resource
+ * @param \Magento\Framework\Model\Resource\Db\Context $context
* @param \Magento\Framework\App\ScopeResolverInterface $scopeResolver
+ * @param string|null $resourcePrefix
* @param null|string $scope
*/
public function __construct(
- \Magento\Framework\App\Resource $resource,
+ \Magento\Framework\Model\Resource\Db\Context $context,
\Magento\Framework\App\ScopeResolverInterface $scopeResolver,
+ $resourcePrefix = null,
$scope = null
) {
$this->scopeResolver = $scopeResolver;
$this->scope = $scope;
- parent::__construct($resource);
+ parent::__construct($context, $resourcePrefix);
}
/**
diff --git a/app/code/Magento/User/Model/Resource/User.php b/app/code/Magento/User/Model/Resource/User.php
index 80c9ddcf11de0..17f4806688a6f 100644
--- a/app/code/Magento/User/Model/Resource/User.php
+++ b/app/code/Magento/User/Model/Resource/User.php
@@ -46,18 +46,20 @@ class User extends \Magento\Framework\Model\Resource\Db\AbstractDb
/**
* Construct
*
- * @param \Magento\Framework\App\Resource $resource
+ * @param \Magento\Framework\Model\Resource\Db\Context $context
* @param \Magento\Framework\Acl\CacheInterface $aclCache
* @param \Magento\Authorization\Model\RoleFactory $roleFactory
* @param \Magento\Framework\Stdlib\DateTime $dateTime
+ * @param string|null $resourcePrefix
*/
public function __construct(
- \Magento\Framework\App\Resource $resource,
+ \Magento\Framework\Model\Resource\Db\Context $context,
\Magento\Framework\Acl\CacheInterface $aclCache,
\Magento\Authorization\Model\RoleFactory $roleFactory,
- \Magento\Framework\Stdlib\DateTime $dateTime
+ \Magento\Framework\Stdlib\DateTime $dateTime,
+ $resourcePrefix = null
) {
- parent::__construct($resource);
+ parent::__construct($context, $resourcePrefix);
$this->_aclCache = $aclCache;
$this->_roleFactory = $roleFactory;
$this->dateTime = $dateTime;
diff --git a/app/code/Magento/Weee/Model/Resource/Attribute/Backend/Weee/Tax.php b/app/code/Magento/Weee/Model/Resource/Attribute/Backend/Weee/Tax.php
index ee2d81eaa9ae6..1c901db9b9c5e 100644
--- a/app/code/Magento/Weee/Model/Resource/Attribute/Backend/Weee/Tax.php
+++ b/app/code/Magento/Weee/Model/Resource/Attribute/Backend/Weee/Tax.php
@@ -18,15 +18,17 @@ class Tax extends \Magento\Framework\Model\Resource\Db\AbstractDb
protected $_storeManager;
/**
- * @param \Magento\Framework\App\Resource $resource
+ * @param \Magento\Framework\Model\Resource\Db\Context $context
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
+ * @param string|null $resourcePrefix
*/
public function __construct(
- \Magento\Framework\App\Resource $resource,
- \Magento\Store\Model\StoreManagerInterface $storeManager
+ \Magento\Framework\Model\Resource\Db\Context $context,
+ \Magento\Store\Model\StoreManagerInterface $storeManager,
+ $resourcePrefix = null
) {
$this->_storeManager = $storeManager;
- parent::__construct($resource);
+ parent::__construct($context, $resourcePrefix);
}
/**
diff --git a/app/code/Magento/Weee/Model/Resource/Tax.php b/app/code/Magento/Weee/Model/Resource/Tax.php
index 54386958b5290..e55e57340028a 100644
--- a/app/code/Magento/Weee/Model/Resource/Tax.php
+++ b/app/code/Magento/Weee/Model/Resource/Tax.php
@@ -19,13 +19,17 @@ class Tax extends \Magento\Framework\Model\Resource\Db\AbstractDb
protected $dateTime;
/**
- * @param \Magento\Framework\App\Resource $resource
+ * @param \Magento\Framework\Model\Resource\Db\Context $context
* @param \Magento\Framework\Stdlib\DateTime $dateTime
+ * @param string|null $resourcePrefix
*/
- public function __construct(\Magento\Framework\App\Resource $resource, \Magento\Framework\Stdlib\DateTime $dateTime)
- {
+ public function __construct(
+ \Magento\Framework\Model\Resource\Db\Context $context,
+ \Magento\Framework\Stdlib\DateTime $dateTime,
+ $resourcePrefix = null
+ ) {
$this->dateTime = $dateTime;
- parent::__construct($resource);
+ parent::__construct($context, $resourcePrefix);
}
/**
diff --git a/app/code/Magento/Widget/Model/Resource/Layout/Update.php b/app/code/Magento/Widget/Model/Resource/Layout/Update.php
index 5da0de6c0477a..4a76d1b721727 100644
--- a/app/code/Magento/Widget/Model/Resource/Layout/Update.php
+++ b/app/code/Magento/Widget/Model/Resource/Layout/Update.php
@@ -19,12 +19,16 @@ class Update extends \Magento\Framework\Model\Resource\Db\AbstractDb
private $_cache;
/**
- * @param \Magento\Framework\App\Resource $resource
+ * @param \Magento\Framework\Model\Resource\Db\Context $context
* @param \Magento\Framework\Cache\FrontendInterface $cache
+ * @param string|null $resourcePrefix
*/
- public function __construct(\Magento\Framework\App\Resource $resource, \Magento\Framework\Cache\FrontendInterface $cache)
- {
- parent::__construct($resource);
+ public function __construct(
+ \Magento\Framework\Model\Resource\Db\Context $context,
+ \Magento\Framework\Cache\FrontendInterface $cache,
+ $resourcePrefix = null
+ ) {
+ parent::__construct($context, $resourcePrefix);
$this->_cache = $cache;
}
diff --git a/app/etc/di.xml b/app/etc/di.xml
index f2994939911af..e189e6742edf3 100755
--- a/app/etc/di.xml
+++ b/app/etc/di.xml
@@ -129,6 +129,8 @@
+
+
Magento\Framework\Filesystem\Driver\File
@@ -300,7 +302,7 @@
Magento\Framework\App\Resource\Config\Reader\Proxy
Magento\Framework\App\Cache\Type\Config\Proxy
- Magento\Framework\App\Resource\Config::PARAM_INITIAL_RESOURCES
+ Magento\Framework\App\DeploymentConfig\ResourceConfig
diff --git a/dev/tests/integration/testsuite/Magento/Framework/Model/Resource/Db/AbstractTest.php b/dev/tests/integration/testsuite/Magento/Framework/Model/Resource/Db/AbstractTest.php
index 8730fa5f88420..bf47aeb3babee 100644
--- a/dev/tests/integration/testsuite/Magento/Framework/Model/Resource/Db/AbstractTest.php
+++ b/dev/tests/integration/testsuite/Magento/Framework/Model/Resource/Db/AbstractTest.php
@@ -18,9 +18,13 @@ class AbstractTest extends \PHPUnit_Framework_TestCase
protected function setUp()
{
$resource = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Framework\App\Resource');
- $this->_model = $this->getMockForAbstractClass('Magento\Framework\Model\Resource\Db\AbstractDb',
+ $context = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
+ '\Magento\Framework\Model\Resource\Db\Context',
['resource' => $resource]
);
+ $this->_model = $this->getMockForAbstractClass('Magento\Framework\Model\Resource\Db\AbstractDb',
+ ['context' => $context]
+ );
}
public function testConstruct()
@@ -54,9 +58,13 @@ public function testGetTableName()
'Magento\Framework\App\Resource',
['tablePrefix' => 'prefix_']
);
+ $context = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
+ '\Magento\Framework\Model\Resource\Db\Context',
+ ['resource' => $resource]
+ );
$model = $this->getMockForAbstractClass('Magento\Framework\Model\Resource\Db\AbstractDb',
- ['resource' => $resource]
+ ['context' => $context]
);
$tableName = $model->getTable([$tableNameOrig, $tableSuffix]);
diff --git a/dev/tests/integration/testsuite/Magento/Framework/Model/Resource/Db/Collection/AbstractTest.php b/dev/tests/integration/testsuite/Magento/Framework/Model/Resource/Db/Collection/AbstractTest.php
index 9a0f7ca1a9bf5..a07cb44bd820c 100644
--- a/dev/tests/integration/testsuite/Magento/Framework/Model/Resource/Db/Collection/AbstractTest.php
+++ b/dev/tests/integration/testsuite/Magento/Framework/Model/Resource/Db/Collection/AbstractTest.php
@@ -16,9 +16,14 @@ protected function setUp()
{
$resourceModel = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
->get('Magento\Framework\App\Resource');
+ $context = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
+ '\Magento\Framework\Model\Resource\Db\Context',
+ ['resource' => $resourceModel]
+ );
+
$resource = $this->getMockForAbstractClass(
'Magento\Framework\Model\Resource\Db\AbstractDb',
- [$resourceModel],
+ [$context],
'',
true,
true,
diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/Resource/AbstractTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Model/Resource/AbstractTest.php
index 0a8c04067abc7..c63bf8f977ec2 100644
--- a/dev/tests/unit/testsuite/Magento/Catalog/Model/Resource/AbstractTest.php
+++ b/dev/tests/unit/testsuite/Magento/Catalog/Model/Resource/AbstractTest.php
@@ -9,6 +9,8 @@
*/
namespace Magento\Catalog\Model\Resource;
+use Magento\TestFramework\Helper\ObjectManager;
+
class AbstractTest extends \PHPUnit_Framework_TestCase
{
/**
@@ -41,6 +43,8 @@ protected function _getAttributes()
public function testWalkAttributes()
{
+ $objectManager = new ObjectManager($this);
+
$code = 'test_attr';
$set = 10;
@@ -78,20 +82,11 @@ public function testWalkAttributes()
$attributes[$code] = $attribute;
/** @var $model \Magento\Catalog\Model\Resource\AbstractResource */
+ $arguments = $objectManager->getConstructArguments('Magento\Catalog\Model\Resource\AbstractResource');
$model = $this->getMock(
'Magento\Catalog\Model\Resource\AbstractResource',
['getAttributesByCode'],
- [
- $this->getMock('Magento\Framework\App\Resource', [], [], '', false, false),
- $this->getMock('Magento\Eav\Model\Config', [], [], '', false, false),
- $this->getMock('Magento\Eav\Model\Entity\Attribute\Set', [], [], '', false, false),
- $this->getMock('Magento\Framework\Locale\FormatInterface'),
- $this->getMock('Magento\Eav\Model\Resource\Helper', [], [], '', false, false),
- $this->getMock('Magento\Framework\Validator\UniversalFactory', [], [], '', false, false),
- $this->getMock('Magento\Store\Model\StoreManagerInterface', [], [], '', false),
- $this->getMock('Magento\Catalog\Model\Factory', [], [], '', false),
- []
- ]
+ $arguments
);
$model->expects($this->once())->method('getAttributesByCode')->will($this->returnValue($attributes));
diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/Resource/Product/FlatTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Model/Resource/Product/FlatTest.php
index 1f17b422ce1bc..1e1931b481680 100644
--- a/dev/tests/unit/testsuite/Magento/Catalog/Model/Resource/Product/FlatTest.php
+++ b/dev/tests/unit/testsuite/Magento/Catalog/Model/Resource/Product/FlatTest.php
@@ -45,7 +45,7 @@ public function setUp()
);
$this->_model = new \Magento\Catalog\Model\Resource\Product\Flat(
- $this->getMock('Magento\Framework\App\Resource', [], [], '', false),
+ $this->getMock('Magento\Framework\Model\Resource\Db\Context', [], [], '', false),
$this->_storeManagerInterface,
$this->getMock('Magento\Catalog\Model\Config', [], [], '', false)
);
diff --git a/dev/tests/unit/testsuite/Magento/Core/Model/Resource/Db/AbstractTest.php b/dev/tests/unit/testsuite/Magento/Core/Model/Resource/Db/AbstractTest.php
index 910071f149816..684b4370e0d1a 100644
--- a/dev/tests/unit/testsuite/Magento/Core/Model/Resource/Db/AbstractTest.php
+++ b/dev/tests/unit/testsuite/Magento/Core/Model/Resource/Db/AbstractTest.php
@@ -24,10 +24,12 @@ class AbstractTest extends \PHPUnit_Framework_TestCase
protected function setUp()
{
$this->_resource = $this->getMock('Magento\Framework\App\Resource', [], [], '', false, false);
+ $contextMock = $this->getMock('\Magento\Framework\Model\Resource\Db\Context', ['getResources'], [], '', false);
+ $contextMock->expects($this->once())->method('getResources')->willReturn($this->_resource);
$this->_model = $this->getMock(
'Magento\Framework\Model\Resource\Db\AbstractDb',
['_construct', '_getWriteAdapter'],
- [$this->_resource]
+ [$contextMock]
);
}
diff --git a/dev/tests/unit/testsuite/Magento/Customer/Model/Resource/GroupTest.php b/dev/tests/unit/testsuite/Magento/Customer/Model/Resource/GroupTest.php
index 496164e7d3e30..62612ced490ff 100644
--- a/dev/tests/unit/testsuite/Magento/Customer/Model/Resource/GroupTest.php
+++ b/dev/tests/unit/testsuite/Magento/Customer/Model/Resource/GroupTest.php
@@ -30,6 +30,9 @@ class GroupTest extends \PHPUnit_Framework_TestCase
/** @var \PHPUnit_Framework_MockObject_MockObject */
protected $groupManagement;
+ /** @var \PHPUnit_Framework_MockObject_MockObject */
+ protected $relationProcessorMock;
+
protected function setUp()
{
$this->resource = $this->getMock('Magento\Framework\App\Resource', [], [], '', false);
@@ -50,10 +53,32 @@ protected function setUp()
$this->groupModel = $this->getMock('Magento\Customer\Model\Group', [], [], '', false);
+ $contextMock = $this->getMock('\Magento\Framework\Model\Resource\Db\Context', [], [], '', false);
+ $contextMock->expects($this->once())->method('getResources')->willReturn($this->resource);
+
+ $this->relationProcessorMock = $this->getMock(
+ '\Magento\Framework\Model\Resource\Db\ObjectRelationProcessor',
+ [],
+ [],
+ '',
+ false
+ );
+
+ $transactionManagerMock = $this->getMock('\Magento\Framework\Model\Resource\Db\TransactionManagerInterface');
+ $transactionManagerMock->expects($this->once())
+ ->method('start')
+ ->willReturn($this->getMock('\Magento\Framework\DB\Adapter\AdapterInterface'));
+ $contextMock->expects($this->once())
+ ->method('getTransactionManager')
+ ->willReturn($transactionManagerMock);
+ $contextMock->expects($this->once())
+ ->method('getObjectRelationProcessor')
+ ->willReturn($this->relationProcessorMock);
+
$this->groupResourceModel = (new ObjectManagerHelper($this))->getObject(
'Magento\Customer\Model\Resource\Group',
[
- 'resource' => $this->resource,
+ 'context' => $contextMock,
'groupManagement' => $this->groupManagement,
'customersFactory' => $this->customersFactory,
]
@@ -93,6 +118,8 @@ public function testDelete()
$this->customersFactory->expects($this->once())->method('create')
->will($this->returnValue($customerCollection));
+ $this->relationProcessorMock->expects($this->once())->method('delete');
+ $this->groupModel->expects($this->any())->method('getData')->willReturn(['data' => 'value']);
$this->groupResourceModel->delete($this->groupModel);
}
}
diff --git a/dev/tests/unit/testsuite/Magento/CustomerImportExport/Model/Resource/Import/CustomerComposite/DataTest.php b/dev/tests/unit/testsuite/Magento/CustomerImportExport/Model/Resource/Import/CustomerComposite/DataTest.php
index b22da5d729f85..8e386570d6c34 100644
--- a/dev/tests/unit/testsuite/Magento/CustomerImportExport/Model/Resource/Import/CustomerComposite/DataTest.php
+++ b/dev/tests/unit/testsuite/Magento/CustomerImportExport/Model/Resource/Import/CustomerComposite/DataTest.php
@@ -99,11 +99,19 @@ public function testGetNextBunch($entityType, $bunchData, $expectedData)
$coreHelper = $this->getMock('Magento\Core\Helper\Data', ['__construct'], [], '', false);
unset($dependencies['resource'], $dependencies['json_helper']);
- $object = new Data(
- $resource,
- $coreHelper,
- $dependencies
+ $contextMock = $this->getMock('\Magento\Framework\Model\Resource\Db\Context', [], [], '', false);
+ $contextMock->expects($this->once())->method('getResources')->willReturn($resource);
+
+ $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this);
+ $object = $objectManager->getObject(
+ '\Magento\CustomerImportExport\Model\Resource\Import\CustomerComposite\Data',
+ [
+ 'context' => $contextMock,
+ 'coreHelper' => $coreHelper,
+ 'arguments' => $dependencies,
+ ]
);
+
$this->assertEquals($expectedData, $object->getNextBunch());
}
diff --git a/dev/tests/unit/testsuite/Magento/Eav/Model/Entity/AbstractTest.php b/dev/tests/unit/testsuite/Magento/Eav/Model/Entity/AbstractTest.php
index a2dd2a161c1e5..78bd87aa00b22 100644
--- a/dev/tests/unit/testsuite/Magento/Eav/Model/Entity/AbstractTest.php
+++ b/dev/tests/unit/testsuite/Magento/Eav/Model/Entity/AbstractTest.php
@@ -5,6 +5,8 @@
*/
namespace Magento\Eav\Model\Entity;
+use Magento\TestFramework\Helper\ObjectManager;
+
class AbstractTest extends \PHPUnit_Framework_TestCase
{
/**
@@ -18,17 +20,15 @@ class AbstractTest extends \PHPUnit_Framework_TestCase
protected function setUp()
{
+ $objectManager = new ObjectManager($this);
$this->eavConfig = $this->getMock('Magento\Eav\Model\Config', [], [], '', false);
+ $arguments = $objectManager->getConstructArguments(
+ 'Magento\Eav\Model\Entity\AbstractEntity',
+ ['eavConfig' => $this->eavConfig]
+ );
$this->_model = $this->getMockForAbstractClass(
'Magento\Eav\Model\Entity\AbstractEntity',
- [
- $this->getMock('Magento\Framework\App\Resource', [], [], '', false),
- $this->eavConfig,
- $this->getMock('Magento\Eav\Model\Entity\Attribute\Set', [], [], '', false),
- $this->getMock('\Magento\Framework\Locale\FormatInterface'),
- $this->getMock('Magento\Eav\Model\Resource\Helper', [], [], '', false),
- $this->getMock('Magento\Framework\Validator\UniversalFactory', [], [], '', false)
- ]
+ $arguments
);
}
@@ -262,31 +262,30 @@ public function testSave($attributeCode, $attributeSetId, $productData, $product
);
$backendModel->setAttribute($attribute);
-
$attribute->expects($this->any())->method('getBackend')->will($this->returnValue($backendModel));
$attribute->setId(222);
-
$attributes[$attributeCode] = $attribute;
-
$eavConfig = $this->getMockBuilder('Magento\Eav\Model\Config')
->disableOriginalConstructor()
->getMock();
-
- $data = [
- $this->getMock('Magento\Framework\App\Resource', [], [], '', false),
- $eavConfig,
- $this->getMock('Magento\Eav\Model\Entity\Attribute\Set', [], [], '', false),
- $this->getMock('Magento\Framework\Locale\FormatInterface'),
- $this->getMock('Magento\Eav\Model\Resource\Helper', [], [], '', false),
- $this->getMock('Magento\Framework\Validator\UniversalFactory', [], [], '', false),
- ['type' => $entityType, 'entityTable' => 'entityTable', 'attributesByCode' => $attributes],
- ];
+ $objectManager = new ObjectManager($this);
+ $this->eavConfig = $this->getMock('Magento\Eav\Model\Config', [], [], '', false);
+ $arguments = $objectManager->getConstructArguments(
+ 'Magento\Eav\Model\Entity\AbstractEntity',
+ [
+ 'eavConfig' => $eavConfig,
+ 'data' => [
+ 'type' => $entityType,
+ 'entityTable' => 'entityTable',
+ 'attributesByCode' => $attributes
+ ]
+ ]
+ );
/** @var $model \Magento\Framework\Model\AbstractModel|\PHPUnit_Framework_MockObject_MockObject */
$model = $this->getMockBuilder('Magento\Eav\Model\Entity\AbstractEntity')
- ->setConstructorArgs($data)
+ ->setConstructorArgs($arguments)
->setMethods(['_getValue', 'beginTransaction', 'commit', 'rollback'])
->getMock();
-
$model->expects($this->any())->method('_getValue')->will($this->returnValue($eavConfig));
$eavConfig->expects($this->any())->method('getAttribute')->will(
$this->returnCallback(
@@ -295,10 +294,8 @@ function ($entityType, $attributeCode) use ($attributes) {
}
)
);
-
$model->setConnection($this->_getAdapterMock());
$model->isPartialSave(true);
-
$model->save($object);
}
diff --git a/dev/tests/unit/testsuite/Magento/Eav/Model/Resource/Entity/Attribute/SetTest.php b/dev/tests/unit/testsuite/Magento/Eav/Model/Resource/Entity/Attribute/SetTest.php
index a0bb1faf46515..307aa0e72079a 100644
--- a/dev/tests/unit/testsuite/Magento/Eav/Model/Resource/Entity/Attribute/SetTest.php
+++ b/dev/tests/unit/testsuite/Magento/Eav/Model/Resource/Entity/Attribute/SetTest.php
@@ -29,14 +29,48 @@ class SetTest extends \PHPUnit_Framework_TestCase
*/
protected $typeMock;
+ /**
+ * @var \PHPUnit_Framework_MockObject_MockObject
+ */
+ protected $transactionManagerMock;
+
+ /**
+ * @var \PHPUnit_Framework_MockObject_MockObject
+ */
+ protected $resourceMock;
+
+ /**
+ * @var \PHPUnit_Framework_MockObject_MockObject
+ */
+ protected $relationProcessor;
+
protected function setUp()
{
+ $this->resourceMock = $this->getMock('\Magento\Framework\App\Resource', ['getConnection'], [], '', false);
+ $this->transactionManagerMock = $this->getMock(
+ '\Magento\Framework\Model\Resource\Db\TransactionManagerInterface'
+ );
+ $this->relationProcessor = $this->getMock(
+ '\Magento\Framework\Model\Resource\Db\ObjectRelationProcessor',
+ [],
+ [],
+ '',
+ false
+ );
+ $contextMock = $this->getMock('Magento\Framework\Model\Resource\Db\Context', [], [], '', false);
+ $contextMock->expects($this->once())
+ ->method('getTransactionManager')
+ ->willReturn($this->transactionManagerMock);
+ $contextMock->expects($this->once())
+ ->method('getObjectRelationProcessor')
+ ->willReturn($this->relationProcessor);
+ $contextMock->expects($this->once())->method('getResources')->willReturn($this->resourceMock);
+
$this->eavConfigMock = $this->getMock('Magento\Eav\Model\Config', [], [], '', false);
$this->model = $this->getMock(
'Magento\Eav\Model\Resource\Entity\Attribute\Set',
[
'beginTransaction',
- '_getWriteAdapter',
'getMainTable',
'getIdFieldName',
'_afterDelete',
@@ -45,7 +79,7 @@ protected function setUp()
'__wakeup'
],
[
- $this->getMock('Magento\Framework\App\Resource', [], [], '', false),
+ $contextMock,
$this->getMock('Magento\Eav\Model\Resource\Entity\Attribute\GroupFactory', [], [], '', false),
$this->eavConfigMock
],
@@ -78,6 +112,15 @@ protected function setUp()
*/
public function testBeforeDeleteStateException()
{
+ $this->resourceMock->expects($this->once())
+ ->method('getConnection')
+ ->willReturn($this->getMock('\Magento\Framework\DB\Adapter\AdapterInterface'));
+
+ $this->transactionManagerMock->expects($this->once())
+ ->method('start')
+ ->with($this->getMock('\Magento\Framework\DB\Adapter\AdapterInterface'))
+ ->willReturn($this->getMock('\Magento\Framework\DB\Adapter\AdapterInterface'));
+
$this->objectMock->expects($this->once())->method('getEntityTypeId')->willReturn(665);
$this->eavConfigMock->expects($this->once())->method('getEntityType')->with(665)->willReturn($this->typeMock);
$this->typeMock->expects($this->once())->method('getDefaultAttributeSetId')->willReturn(4);
@@ -92,12 +135,21 @@ public function testBeforeDeleteStateException()
*/
public function testBeforeDelete()
{
+ $this->resourceMock->expects($this->once())
+ ->method('getConnection')
+ ->willReturn($this->getMock('\Magento\Framework\DB\Adapter\AdapterInterface'));
+
+ $this->transactionManagerMock->expects($this->once())
+ ->method('start')
+ ->with($this->getMock('\Magento\Framework\DB\Adapter\AdapterInterface'))
+ ->willReturn($this->getMock('\Magento\Framework\DB\Adapter\AdapterInterface'));
+
$this->objectMock->expects($this->once())->method('getEntityTypeId')->willReturn(665);
$this->eavConfigMock->expects($this->once())->method('getEntityType')->with(665)->willReturn($this->typeMock);
$this->typeMock->expects($this->once())->method('getDefaultAttributeSetId')->willReturn(4);
$this->objectMock->expects($this->once())->method('getAttributeSetId')->willReturn(5);
- $this->model->expects($this->once())
- ->method('_getWriteAdapter')
+ $this->relationProcessor->expects($this->once())
+ ->method('delete')
->willThrowException(new \Exception('test exception'));
$this->model->delete($this->objectMock);
diff --git a/dev/tests/unit/testsuite/Magento/Eav/Model/Resource/Entity/AttributeTest.php b/dev/tests/unit/testsuite/Magento/Eav/Model/Resource/Entity/AttributeTest.php
index bf026916f6187..2b9cb6b59aab4 100644
--- a/dev/tests/unit/testsuite/Magento/Eav/Model/Resource/Entity/AttributeTest.php
+++ b/dev/tests/unit/testsuite/Magento/Eav/Model/Resource/Entity/AttributeTest.php
@@ -271,8 +271,21 @@ protected function _prepareResourceModel()
$resource->expects($this->any())->method('getTableName')->will($this->returnArgument(0));
$resource->expects($this->any())->method('getConnection')->with()->will($this->returnValue($adapter));
$eavEntityType = $this->getMock('Magento\Eav\Model\Resource\Entity\Type', [], [], '', false, false);
+
+ $relationProcessorMock = $this->getMock(
+ '\Magento\Framework\Model\Resource\Db\ObjectRelationProcessor',
+ [],
+ [],
+ '',
+ false
+ );
+
+ $contextMock = $this->getMock('\Magento\Framework\Model\Resource\Db\Context', [], [], '', false);
+ $contextMock->expects($this->once())->method('getResources')->willReturn($resource);
+ $contextMock->expects($this->once())->method('getObjectRelationProcessor')->willReturn($relationProcessorMock);
+
$arguments = [
- 'resource' => $resource,
+ 'context' => $contextMock,
'storeManager' => $storeManager,
'eavEntityType' => $eavEntityType,
];
diff --git a/dev/tests/unit/testsuite/Magento/Framework/App/Resource/ConfigTest.php b/dev/tests/unit/testsuite/Magento/Framework/App/Resource/ConfigTest.php
index a072a11f71a7f..7dfa5530da411 100644
--- a/dev/tests/unit/testsuite/Magento/Framework/App/Resource/ConfigTest.php
+++ b/dev/tests/unit/testsuite/Magento/Framework/App/Resource/ConfigTest.php
@@ -65,12 +65,18 @@ protected function setUp()
$this->returnValue(serialize($this->_resourcesConfig))
);
+ $deploymentConfigMock = $this->getMock('\Magento\Framework\App\DeploymentConfig', [], [], '', false);
+ $deploymentConfigMock->expects($this->once())
+ ->method('getSegment')
+ ->with('resource')
+ ->willReturn($this->_initialResources);
+
$this->_model = new \Magento\Framework\App\Resource\Config(
$this->_readerMock,
$this->_scopeMock,
$this->_cacheMock,
- 'cacheId',
- $this->_initialResources
+ $deploymentConfigMock,
+ 'cacheId'
);
}
@@ -89,12 +95,18 @@ public function testGetConnectionName($resourceName, $connectionName)
*/
public function testExceptionConstructor()
{
+ $deploymentConfigMock = $this->getMock('\Magento\Framework\App\DeploymentConfig', [], [], '', false);
+ $deploymentConfigMock->expects($this->once())
+ ->method('getSegment')
+ ->with('resource')
+ ->willReturn(['validResource' => ['somekey' => 'validConnectionName']]);
+
new \Magento\Framework\App\Resource\Config(
$this->_readerMock,
$this->_scopeMock,
$this->_cacheMock,
- 'cacheId',
- ['validResource' => ['somekey' => 'validConnectionName']]
+ $deploymentConfigMock,
+ 'cacheId'
);
}
@@ -110,7 +122,7 @@ public function getConnectionNameDataProvider()
'resourceName' => 'brokenResourceName',
'connectionName' => \Magento\Framework\App\Resource\Config::DEFAULT_SETUP_CONNECTION
],
- ['resourceName' => 'extendedResourceName', 'connectionName' => 'default'],
+ ['resourceName' => 'extendedResourceName', 'connectionName' => 'validConnectionName'],
['resourceName' => 'validResource', 'connectionName' => 'validConnectionName']
];
}
diff --git a/dev/tests/unit/testsuite/Magento/Framework/FlagTest.php b/dev/tests/unit/testsuite/Magento/Framework/FlagTest.php
index 8b2f0ea87a486..00f19612c1a2c 100644
--- a/dev/tests/unit/testsuite/Magento/Framework/FlagTest.php
+++ b/dev/tests/unit/testsuite/Magento/Framework/FlagTest.php
@@ -48,10 +48,15 @@ protected function createInstance(array $data = [])
->method('getConnection')
->will($this->returnValue($adapter));
- $resource = $this->getMockBuilder('Magento\Framework\Flag\Resource')
- ->setMethods(['__wakeup', 'load', 'save', 'addCommitCallback', 'commit', 'rollBack'])
- ->setConstructorArgs(['resource' => $appResource])
- ->getMockForAbstractClass();
+ $dbContextMock = $this->getMock('\Magento\Framework\Model\Resource\Db\Context', [], [], '', false);
+ $dbContextMock->expects($this->once())->method('getResources')->willReturn($appResource);
+ $resource = $this->getMock(
+ '\Magento\Framework\Flag\Resource',
+ ['__wakeup', 'load', 'save', 'addCommitCallback', 'commit', 'rollBack'],
+ ['context' => $dbContextMock],
+ '',
+ true
+ );
$resource->expects($this->any())
->method('addCommitCallback')
->will($this->returnSelf());
diff --git a/dev/tests/unit/testsuite/Magento/Framework/Model/Resource/Db/AbstractDbTest.php b/dev/tests/unit/testsuite/Magento/Framework/Model/Resource/Db/AbstractDbTest.php
index f349fb2b77ebc..115b2ba5f94c0 100644
--- a/dev/tests/unit/testsuite/Magento/Framework/Model/Resource/Db/AbstractDbTest.php
+++ b/dev/tests/unit/testsuite/Magento/Framework/Model/Resource/Db/AbstractDbTest.php
@@ -20,6 +20,16 @@ class AbstractDbTest extends \PHPUnit_Framework_TestCase
*/
protected $_resourcesMock;
+ /**
+ * @var \PHPUnit_Framework_MockObject_MockObject
+ */
+ protected $transactionManagerMock;
+
+ /**
+ * @var \PHPUnit_Framework_MockObject_MockObject
+ */
+ protected $relationProcessorMock;
+
protected function setUp()
{
$this->_resourcesMock = $this->getMock(
@@ -30,9 +40,28 @@ protected function setUp()
false
);
+ $this->relationProcessorMock = $this->getMock(
+ '\Magento\Framework\Model\Resource\Db\ObjectRelationProcessor',
+ [],
+ [],
+ '',
+ false
+ );
+ $this->transactionManagerMock = $this->getMock(
+ '\Magento\Framework\Model\Resource\Db\TransactionManagerInterface'
+ );
+ $contextMock = $this->getMock('\Magento\Framework\Model\Resource\Db\Context', [], [], '', false);
+ $contextMock->expects($this->once())->method('getResources')->willReturn($this->_resourcesMock);
+ $contextMock->expects($this->once())
+ ->method('getObjectRelationProcessor')
+ ->willReturn($this->relationProcessorMock);
+ $contextMock->expects($this->once())
+ ->method('getTransactionManager')
+ ->willReturn($this->transactionManagerMock);
+
$this->_model = $this->getMockForAbstractClass(
'Magento\Framework\Model\Resource\Db\AbstractDb',
- [$this->_resourcesMock]
+ [$contextMock]
);
}
@@ -277,12 +306,32 @@ public function testDelete()
false,
true,
true,
- ['__wakeup', 'getId', 'beforeDelete', 'afterDelete', 'afterDeleteCommit']
+ ['__wakeup', 'getId', 'beforeDelete', 'afterDelete', 'afterDeleteCommit', 'getData']
);
$this->_resourcesMock->expects($this->any())
->method('getConnection')
->will($this->returnValue($adapterInterfaceMock)
);
+
+ $abstractModelMock->expects($this->once())->method('getData')->willReturn(['data' => 'value']);
+ $connectionMock = $this->getMock('\Magento\Framework\DB\Adapter\AdapterInterface');
+ $this->transactionManagerMock->expects($this->once())
+ ->method('start')
+ ->with($adapterInterfaceMock)
+ ->willReturn($connectionMock);
+
+ $this->relationProcessorMock->expects($this->once())
+ ->method('delete')
+ ->with(
+ $this->transactionManagerMock,
+ $connectionMock,
+ 'tableName',
+ 'idFieldName',
+ ['data' => 'value']
+ );
+
+ $this->transactionManagerMock->expects($this->once())->method('commit');
+
$data = 'tableName';
$this->_resourcesMock->expects($this->any())->method('getTableName')->with($data)->will(
$this->returnValue('tableName')
diff --git a/dev/tests/unit/testsuite/Magento/Indexer/Model/Resource/AbstractResourceTest.php b/dev/tests/unit/testsuite/Magento/Indexer/Model/Resource/AbstractResourceTest.php
index ddb305a390221..e4364e8d9a276 100644
--- a/dev/tests/unit/testsuite/Magento/Indexer/Model/Resource/AbstractResourceTest.php
+++ b/dev/tests/unit/testsuite/Magento/Indexer/Model/Resource/AbstractResourceTest.php
@@ -17,55 +17,21 @@ class AbstractResourceTest extends \PHPUnit_Framework_TestCase
*/
protected $_resourceMock;
- /**
- * @var \Magento\Catalog\Model\CategoryFactory|\PHPUnit_Framework_MockObject_MockObject
- */
- protected $_categoryFactoryMock;
-
- /**
- * @var \Magento\Catalog\Model\Resource\Category\CollectionFactory|\PHPUnit_Framework_MockObject_MockObject
- */
- protected $_categoryCollectionFactoryMock;
-
- /**
- * @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject
- */
- protected $_storeManagerMock;
-
- /**
- * @var \Magento\Catalog\Model\Config|\PHPUnit_Framework_MockObject_MockObject
- */
- protected $_catalogConfigMock;
-
- /**
- * @var \Magento\Framework\Event\ManagerInterface|\PHPUnit_Framework_MockObject_MockObject
- */
- protected $_eventManagerMock;
protected function setUp()
{
$this->_resourceMock = $this->getMockBuilder('Magento\Framework\App\Resource')
->disableOriginalConstructor()
->getMock();
- $this->_categoryFactoryMock = $this->getMockBuilder('Magento\Catalog\Model\CategoryFactory')
- ->disableOriginalConstructor()
- ->getMock();
- $this->_categoryCollectionFactoryMock = $this->getMockBuilder(
- 'Magento\Catalog\Model\Resource\Category\CollectionFactory'
- )->disableOriginalConstructor()->getMock();
- $this->_storeManagerMock = $this->getMock('Magento\Store\Model\StoreManagerInterface');
- $this->_catalogConfigMock = $this->getMockBuilder('Magento\Catalog\Model\Config')
- ->disableOriginalConstructor()
- ->getMock();
- $this->_eventManagerMock = $this->getMock('Magento\Framework\Event\ManagerInterface');
-
- $this->model = new \Magento\Indexer\Model\Resource\AbstractResourceStub(
- $this->_resourceMock,
- $this->_categoryFactoryMock,
- $this->_categoryCollectionFactoryMock,
- $this->_storeManagerMock,
- $this->_catalogConfigMock,
- $this->_eventManagerMock
+
+ $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this);
+ $arguments = $objectManager->getConstructArguments(
+ '\Magento\Indexer\Model\Resource\AbstractResourceStub',
+ ['resource' => $this->_resourceMock]
+ );
+ $this->model = $objectManager->getObject(
+ '\Magento\Indexer\Model\Resource\AbstractResourceStub',
+ $arguments
);
}
@@ -86,9 +52,7 @@ public function testUseIdxTable()
public function testClearTemporaryIndexTable()
{
$connectionMock = $this->getMock('Magento\Framework\DB\Adapter\AdapterInterface', [], [], '', false);
- $storeMock = $this->getMock('Magento\Store\Model\Store', [], [], '', false);
$this->_resourceMock->expects($this->any())->method('getConnection')->will($this->returnValue($connectionMock));
- $this->_storeManagerMock->expects($this->any())->method('getStore')->will($this->returnValue($storeMock));
$connectionMock->expects($this->once())->method('delete')->will($this->returnSelf());
$this->model->clearTemporaryIndexTable();
}
@@ -101,7 +65,6 @@ public function testSyncData()
$selectMock = $this->getMock('Magento\Framework\DB\Select', [], [], '', false);
$connectionMock = $this->getMock('Magento\Framework\DB\Adapter\AdapterInterface', [], [], '', false);
- $storeMock = $this->getMock('Magento\Store\Model\Store', [], [], '', false);
$connectionMock->expects($this->any())->method('describeTable')->will($this->returnValue($describeTable));
$connectionMock->expects($this->any())->method('select')->will($this->returnValue($selectMock));
@@ -112,7 +75,6 @@ public function testSyncData()
$resultColumns
)->will($this->returnSelf());
- $this->_storeManagerMock->expects($this->any())->method('getStore')->will($this->returnValue($storeMock));
$this->_resourceMock->expects($this->any())->method('getConnection')->will($this->returnValue($connectionMock));
$this->_resourceMock->expects($this->any())->method('getTableName')->will($this->returnArgument(0));
@@ -147,13 +109,11 @@ public function testInsertFromTable($readToIndex)
$selectMock = $this->getMock('Magento\Framework\DB\Select', [], [], '', false);
$connectionMock = $this->getMock('Magento\Framework\DB\Adapter\AdapterInterface', [], [], '', false);
- $storeMock = $this->getMock('Magento\Store\Model\Store', [], [], '', false);
$connectionMock->expects($this->any())->method('describeTable')->will($this->returnValue($tableColumns));
$connectionMock->expects($this->any())->method('select')->will($this->returnValue($selectMock));
$selectMock->expects($this->any())->method('from')->will($this->returnSelf());
- $this->_storeManagerMock->expects($this->any())->method('getStore')->will($this->returnValue($storeMock));
if ($readToIndex) {
$connectionCustomMock = $this->getMock(
'Magento\Framework\DB\Adapter\CustomAdapterInterface',
diff --git a/dev/tests/unit/testsuite/Magento/Indexer/Model/Resource/Indexer/StateTest.php b/dev/tests/unit/testsuite/Magento/Indexer/Model/Resource/Indexer/StateTest.php
index d86b9e821857e..b9e2c8fd05fce 100644
--- a/dev/tests/unit/testsuite/Magento/Indexer/Model/Resource/Indexer/StateTest.php
+++ b/dev/tests/unit/testsuite/Magento/Indexer/Model/Resource/Indexer/StateTest.php
@@ -21,7 +21,15 @@ public function testConstruct()
'',
false
);
- $this->model = new \Magento\Indexer\Model\Resource\Indexer\State($resourceMock);
+ $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this);
+ $arguments = $objectManager->getConstructArguments(
+ '\Magento\Indexer\Model\Resource\Indexer\State',
+ ['resource' => $resourceMock]
+ );
+ $this->model = $objectManager->getObject(
+ '\Magento\Indexer\Model\Resource\Indexer\State',
+ $arguments
+ );
$this->assertEquals(
[['field' => ['indexer_id'], 'title' => __('State for the same indexer')]],
$this->model->getUniqueFields()
diff --git a/dev/tests/unit/testsuite/Magento/Indexer/Model/Resource/Mview/View/StateTest.php b/dev/tests/unit/testsuite/Magento/Indexer/Model/Resource/Mview/View/StateTest.php
index d368babe616f8..6eeb39aa40d42 100644
--- a/dev/tests/unit/testsuite/Magento/Indexer/Model/Resource/Mview/View/StateTest.php
+++ b/dev/tests/unit/testsuite/Magento/Indexer/Model/Resource/Mview/View/StateTest.php
@@ -21,7 +21,15 @@ public function testConstruct()
'',
false
);
- $this->model = new \Magento\Indexer\Model\Resource\Mview\View\State($resourceMock);
+ $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this);
+ $arguments = $objectManager->getConstructArguments(
+ '\Magento\Indexer\Model\Resource\Mview\View\State',
+ ['resource' => $resourceMock]
+ );
+ $this->model = $objectManager->getObject(
+ '\Magento\Indexer\Model\Resource\Mview\View\State',
+ $arguments
+ );
$this->assertEquals(
[['field' => ['view_id'], 'title' => __('State for the same view')]],
$this->model->getUniqueFields()
diff --git a/dev/tests/unit/testsuite/Magento/Quote/Model/Resource/QuoteTest.php b/dev/tests/unit/testsuite/Magento/Quote/Model/Resource/QuoteTest.php
index 4742a456a74db..bd2902942609b 100644
--- a/dev/tests/unit/testsuite/Magento/Quote/Model/Resource/QuoteTest.php
+++ b/dev/tests/unit/testsuite/Magento/Quote/Model/Resource/QuoteTest.php
@@ -52,8 +52,11 @@ protected function setUp()
$this->configMock = $this->getMock('\Magento\Eav\Model\Config', [], [], '', false);
+ $contextMock = $this->getMock('\Magento\Framework\Model\Resource\Db\Context', [], [], '', false);
+ $contextMock->expects($this->once())->method('getResources')->willReturn($this->resourceMock);
+
$this->model = new \Magento\Quote\Model\Resource\Quote(
- $this->resourceMock,
+ $contextMock,
$this->configMock
);
}
diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/Order/Creditmemo/CommentTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/Order/Creditmemo/CommentTest.php
index 4baf111f99b7b..f4221f175a332 100644
--- a/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/Order/Creditmemo/CommentTest.php
+++ b/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/Order/Creditmemo/CommentTest.php
@@ -80,11 +80,24 @@ protected function setUp()
->method('lastInsertId');
$this->commentModelMock->expects($this->any())->method('hasDataChanges')->will($this->returnValue(true));
$this->commentModelMock->expects($this->any())->method('isSaveAllowed')->will($this->returnValue(true));
+
+ $relationProcessorMock = $this->getMock(
+ '\Magento\Framework\Model\Resource\Db\ObjectRelationProcessor',
+ [],
+ [],
+ '',
+ false
+ );
+
+ $contextMock = $this->getMock('\Magento\Framework\Model\Resource\Db\Context', [], [], '', false);
+ $contextMock->expects($this->once())->method('getResources')->willReturn($this->appResourceMock);
+ $contextMock->expects($this->once())->method('getObjectRelationProcessor')->willReturn($relationProcessorMock);
+
$objectManager = new \Magento\TestFramework\Helper\ObjectManager($this);
$this->commentResource = $objectManager->getObject(
'Magento\Sales\Model\Resource\Order\Creditmemo\Comment',
[
- 'resource' => $this->appResourceMock,
+ 'context' => $contextMock,
'validator' => $this->validatorMock
]
);
@@ -99,6 +112,8 @@ public function testSave()
->method('validate')
->with($this->equalTo($this->commentModelMock))
->will($this->returnValue([]));
+
+ $this->commentModelMock->expects($this->any())->method('getData')->willReturn([]);
$this->commentResource->save($this->commentModelMock);
$this->assertTrue(true);
}
diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/Order/Creditmemo/GridTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/Order/Creditmemo/GridTest.php
index 3c7eac389109f..24ffb0c200798 100644
--- a/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/Order/Creditmemo/GridTest.php
+++ b/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/Order/Creditmemo/GridTest.php
@@ -85,9 +85,10 @@ public function setUp()
true,
[]
);
- $this->grid = new \Magento\Sales\Model\Resource\Order\Creditmemo\Grid(
- $this->appResourceMock
- );
+
+ $contextMock = $this->getMock('\Magento\Framework\Model\Resource\Db\Context', [], [], '', false);
+ $contextMock->expects($this->once())->method('getResources')->willReturn($this->appResourceMock);
+ $this->grid = new \Magento\Sales\Model\Resource\Order\Creditmemo\Grid($contextMock);
}
/**
diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/Order/GridTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/Order/GridTest.php
index 9b6acb658f5f3..186ad505336a8 100644
--- a/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/Order/GridTest.php
+++ b/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/Order/GridTest.php
@@ -85,9 +85,10 @@ public function setUp()
true,
[]
);
- $this->grid = new \Magento\Sales\Model\Resource\Order\Grid(
- $this->appResourceMock
- );
+
+ $contextMock = $this->getMock('\Magento\Framework\Model\Resource\Db\Context', [], [], '', false);
+ $contextMock->expects($this->once())->method('getResources')->willReturn($this->appResourceMock);
+ $this->grid = new \Magento\Sales\Model\Resource\Order\Grid($contextMock);
}
/**
diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/Order/Invoice/CommentTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/Order/Invoice/CommentTest.php
index 059579ac9d40b..f3055b7a47825 100644
--- a/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/Order/Invoice/CommentTest.php
+++ b/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/Order/Invoice/CommentTest.php
@@ -80,11 +80,24 @@ protected function setUp()
->method('lastInsertId');
$this->commentModelMock->expects($this->any())->method('hasDataChanges')->will($this->returnValue(true));
$this->commentModelMock->expects($this->any())->method('isSaveAllowed')->will($this->returnValue(true));
+
+ $relationProcessorMock = $this->getMock(
+ '\Magento\Framework\Model\Resource\Db\ObjectRelationProcessor',
+ [],
+ [],
+ '',
+ false
+ );
+
+ $contextMock = $this->getMock('\Magento\Framework\Model\Resource\Db\Context', [], [], '', false);
+ $contextMock->expects($this->once())->method('getResources')->willReturn($this->appResourceMock);
+ $contextMock->expects($this->once())->method('getObjectRelationProcessor')->willReturn($relationProcessorMock);
+
$objectManager = new \Magento\TestFramework\Helper\ObjectManager($this);
$this->commentResource = $objectManager->getObject(
'Magento\Sales\Model\Resource\Order\Invoice\Comment',
[
- 'resource' => $this->appResourceMock,
+ 'context' => $contextMock,
'validator' => $this->validatorMock
]
);
@@ -99,6 +112,7 @@ public function testSave()
->method('validate')
->with($this->equalTo($this->commentModelMock))
->will($this->returnValue([]));
+ $this->commentModelMock->expects($this->any())->method('getData')->willReturn([]);
$this->commentResource->save($this->commentModelMock);
$this->assertTrue(true);
}
diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/Order/Invoice/GridTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/Order/Invoice/GridTest.php
index a8e1fce776d15..481c0ad8f8778 100644
--- a/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/Order/Invoice/GridTest.php
+++ b/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/Order/Invoice/GridTest.php
@@ -85,9 +85,9 @@ public function setUp()
true,
[]
);
- $this->grid = new \Magento\Sales\Model\Resource\Order\Invoice\Grid(
- $this->appResourceMock
- );
+ $contextMock = $this->getMock('\Magento\Framework\Model\Resource\Db\Context', [], [], '', false);
+ $contextMock->expects($this->once())->method('getResources')->willReturn($this->appResourceMock);
+ $this->grid = new \Magento\Sales\Model\Resource\Order\Invoice\Grid($contextMock);
}
/**
diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/Order/Shipment/CommentTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/Order/Shipment/CommentTest.php
index 06b8a9583611a..00479e1f49b15 100644
--- a/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/Order/Shipment/CommentTest.php
+++ b/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/Order/Shipment/CommentTest.php
@@ -80,11 +80,24 @@ protected function setUp()
->method('lastInsertId');
$this->commentModelMock->expects($this->any())->method('hasDataChanges')->will($this->returnValue(true));
$this->commentModelMock->expects($this->any())->method('isSaveAllowed')->will($this->returnValue(true));
+
+ $relationProcessorMock = $this->getMock(
+ '\Magento\Framework\Model\Resource\Db\ObjectRelationProcessor',
+ [],
+ [],
+ '',
+ false
+ );
+
+ $contextMock = $this->getMock('\Magento\Framework\Model\Resource\Db\Context', [], [], '', false);
+ $contextMock->expects($this->once())->method('getResources')->willReturn($this->appResourceMock);
+ $contextMock->expects($this->once())->method('getObjectRelationProcessor')->willReturn($relationProcessorMock);
+
$objectManager = new \Magento\TestFramework\Helper\ObjectManager($this);
$this->commentResource = $objectManager->getObject(
'Magento\Sales\Model\Resource\Order\Shipment\Comment',
[
- 'resource' => $this->appResourceMock,
+ 'context' => $contextMock,
'validator' => $this->validatorMock
]
);
@@ -99,6 +112,7 @@ public function testSave()
->method('validate')
->with($this->equalTo($this->commentModelMock))
->will($this->returnValue([]));
+ $this->commentModelMock->expects($this->any())->method('getData')->willReturn([]);
$this->commentResource->save($this->commentModelMock);
$this->assertTrue(true);
}
diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/Order/Shipment/GridTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/Order/Shipment/GridTest.php
index f737ca3604c72..c0c2b7d0f1705 100644
--- a/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/Order/Shipment/GridTest.php
+++ b/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/Order/Shipment/GridTest.php
@@ -85,9 +85,9 @@ public function setUp()
true,
[]
);
- $this->grid = new \Magento\Sales\Model\Resource\Order\Shipment\Grid(
- $this->appResourceMock
- );
+ $contextMock = $this->getMock('\Magento\Framework\Model\Resource\Db\Context', [], [], '', false);
+ $contextMock->expects($this->once())->method('getResources')->willReturn($this->appResourceMock);
+ $this->grid = new \Magento\Sales\Model\Resource\Order\Shipment\Grid($contextMock);
}
/**
diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/Order/Shipment/TrackTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/Order/Shipment/TrackTest.php
index 28792abca4c16..61e6edad93ccf 100644
--- a/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/Order/Shipment/TrackTest.php
+++ b/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/Order/Shipment/TrackTest.php
@@ -81,11 +81,23 @@ protected function setUp()
$this->trackModelMock->expects($this->any())->method('hasDataChanges')->will($this->returnValue(true));
$this->trackModelMock->expects($this->any())->method('isSaveAllowed')->will($this->returnValue(true));
+ $relationProcessorMock = $this->getMock(
+ '\Magento\Framework\Model\Resource\Db\ObjectRelationProcessor',
+ [],
+ [],
+ '',
+ false
+ );
+
+ $contextMock = $this->getMock('\Magento\Framework\Model\Resource\Db\Context', [], [], '', false);
+ $contextMock->expects($this->once())->method('getResources')->willReturn($this->appResourceMock);
+ $contextMock->expects($this->once())->method('getObjectRelationProcessor')->willReturn($relationProcessorMock);
+
$objectManager = new \Magento\TestFramework\Helper\ObjectManager($this);
$this->trackResource = $objectManager->getObject(
'Magento\Sales\Model\Resource\Order\Shipment\Track',
[
- 'resource' => $this->appResourceMock,
+ 'context' => $contextMock,
'validator' => $this->validatorMock
]
);
@@ -100,6 +112,7 @@ public function testSave()
->method('validate')
->with($this->equalTo($this->trackModelMock))
->will($this->returnValue([]));
+ $this->trackModelMock->expects($this->any())->method('getData')->willReturn([]);
$this->trackResource->save($this->trackModelMock);
$this->assertTrue(true);
}
@@ -116,6 +129,7 @@ public function testSaveValidationFailed()
->method('validate')
->with($this->equalTo($this->trackModelMock))
->will($this->returnValue(['warning message']));
+ $this->trackModelMock->expects($this->any())->method('getData')->willReturn([]);
$this->trackResource->save($this->trackModelMock);
$this->assertTrue(true);
}
diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/Order/Status/HistoryTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/Order/Status/HistoryTest.php
index 652cacb17f653..b4a55c1377d8c 100644
--- a/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/Order/Status/HistoryTest.php
+++ b/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/Order/Status/HistoryTest.php
@@ -70,10 +70,23 @@ public function setUp()
->method('insert');
$this->adapterMock->expects($this->any())
->method('lastInsertId');
+
+ $relationProcessorMock = $this->getMock(
+ '\Magento\Framework\Model\Resource\Db\ObjectRelationProcessor',
+ [],
+ [],
+ '',
+ false
+ );
+
+ $contextMock = $this->getMock('\Magento\Framework\Model\Resource\Db\Context', [], [], '', false);
+ $contextMock->expects($this->once())->method('getResources')->willReturn($this->appResourceMock);
+ $contextMock->expects($this->once())->method('getObjectRelationProcessor')->willReturn($relationProcessorMock);
+
$this->historyResource = $objectManager->getObject(
'Magento\Sales\Model\Resource\Order\Status\History',
[
- 'resource' => $this->appResourceMock,
+ 'context' => $contextMock,
'validator' => $this->validatorMock
]
);
@@ -97,6 +110,7 @@ public function testSave()
->method('validate')
->with($historyMock)
->will($this->returnValue([]));
+ $historyMock->expects($this->any())->method('getData')->willReturn([]);
$this->historyResource->save($historyMock);
}
diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/OrderTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/OrderTest.php
index 9059eeced38ad..69eeb3401d260 100644
--- a/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/OrderTest.php
+++ b/dev/tests/unit/testsuite/Magento/Sales/Model/Resource/OrderTest.php
@@ -144,8 +144,11 @@ public function setUp()
false
);
+ $contextMock = $this->getMock('\Magento\Framework\Model\Resource\Db\Context', [], [], '', false);
+ $contextMock->expects($this->once())->method('getResources')->willReturn($this->resourceMock);
+
$this->resource = new Order(
- $this->resourceMock,
+ $contextMock,
$this->attributeMock,
$this->salesIncrementMock,
$this->addressHandlerMock,
diff --git a/dev/tests/unit/testsuite/Magento/Setup/Module/SetupFactoryTest.php b/dev/tests/unit/testsuite/Magento/Setup/Module/SetupFactoryTest.php
index 4c5ca898699ad..7ecc25c8573f8 100644
--- a/dev/tests/unit/testsuite/Magento/Setup/Module/SetupFactoryTest.php
+++ b/dev/tests/unit/testsuite/Magento/Setup/Module/SetupFactoryTest.php
@@ -28,6 +28,14 @@ protected function setUp()
'Magento\Framework\App\DeploymentConfig\Reader',
$this->getMock('Magento\Framework\App\DeploymentConfig\Reader', [], [], '', false),
],
+ [
+ 'Magento\Framework\Model\Resource\Db\TransactionManager',
+ $this->getMock('Magento\Framework\Model\Resource\Db\TransactionManager', [], [], '', false),
+ ],
+ [
+ 'Magento\Framework\Model\Resource\Db\ObjectRelationProcessor',
+ $this->getMock('Magento\Framework\Model\Resource\Db\ObjectRelationProcessor', [], [], '', false),
+ ],
];
$serviceLocatorMock = $this->getMockForAbstractClass('Zend\ServiceManager\ServiceLocatorInterface', ['get']);
diff --git a/dev/tests/unit/testsuite/Magento/Setup/Module/SetupModuleTest.php b/dev/tests/unit/testsuite/Magento/Setup/Module/SetupModuleTest.php
index 75fabe08645a2..675ee17fc4c8d 100644
--- a/dev/tests/unit/testsuite/Magento/Setup/Module/SetupModuleTest.php
+++ b/dev/tests/unit/testsuite/Magento/Setup/Module/SetupModuleTest.php
@@ -54,12 +54,16 @@ public function testApplyRecurringUpdatesWithValidFile()
$this->loggerMock
->expects($this->once())
->method('log');
+
+ $contextMock = $this->getMock('\Magento\Framework\Model\Resource\Db\Context', [], [], '', false);
+ $contextMock->expects($this->any())->method('getResources')->willReturn($this->resourceModelMock);
+
$setupModule = new SetupModule(
$this->loggerMock,
$this->moduleListMock,
$fileResolver,
$this->moduleName,
- $this->resourceModelMock
+ $contextMock
);
$setupModule = $setupModule->applyRecurringUpdates();
$this->assertInstanceOf('Magento\Setup\Module\SetupModule', $setupModule);
@@ -80,12 +84,16 @@ public function testApplyRecurringUpdatesWithInvalidFile()
$this->loggerMock
->expects($this->once())
->method('log');
+
+ $contextMock = $this->getMock('\Magento\Framework\Model\Resource\Db\Context', [], [], '', false);
+ $contextMock->expects($this->any())->method('getResources')->willReturn($this->resourceModelMock);
+
$setupModule = new SetupModule(
$this->loggerMock,
$this->moduleListMock,
$fileResolver,
$this->moduleName,
- $this->resourceModelMock
+ $contextMock
);
$setupModule->applyRecurringUpdates();
}
@@ -97,12 +105,16 @@ public function testApplyUpdatesWithNullResource()
->expects($this->once())
->method('getResourceCode')
->will($this->returnValue(null));
+
+ $contextMock = $this->getMock('\Magento\Framework\Model\Resource\Db\Context', [], [], '', false);
+ $contextMock->expects($this->any())->method('getResources')->willReturn($this->resourceModelMock);
+
$setupModule = new SetupModule(
$this->loggerMock,
$this->moduleListMock,
$fileResolver,
$this->moduleName,
- $this->resourceModelMock
+ $contextMock
);
$setupModule = $setupModule->applyUpdates();
$this->assertInstanceOf('Magento\Setup\Module\SetupModule', $setupModule);
@@ -111,12 +123,16 @@ public function testApplyUpdatesWithNullResource()
public function testApplyUpdatesWithNoVersions()
{
$fileResolver = $this->getMock('Magento\Setup\Module\Setup\FileResolver', [], [], '', false);
+
+ $contextMock = $this->getMock('\Magento\Framework\Model\Resource\Db\Context', [], [], '', false);
+ $contextMock->expects($this->any())->method('getResources')->willReturn($this->resourceModelMock);
+
$setupModule = new SetupModule(
$this->loggerMock,
$this->moduleListMock,
$fileResolver,
$this->moduleName,
- $this->resourceModelMock
+ $contextMock
);
$setupModule = $setupModule->applyUpdates();
$this->assertInstanceOf('Magento\Setup\Module\SetupModule', $setupModule);
diff --git a/dev/tests/unit/testsuite/Magento/Weee/Model/Resource/Attribute/Backend/Weee/TaxTest.php b/dev/tests/unit/testsuite/Magento/Weee/Model/Resource/Attribute/Backend/Weee/TaxTest.php
index 96cdfee93ffa5..73cbff4bcf9f2 100644
--- a/dev/tests/unit/testsuite/Magento/Weee/Model/Resource/Attribute/Backend/Weee/TaxTest.php
+++ b/dev/tests/unit/testsuite/Magento/Weee/Model/Resource/Attribute/Backend/Weee/TaxTest.php
@@ -42,8 +42,11 @@ protected function setUp()
->method('getTableName')
->willReturn('table_name');
+ $contextMock = $this->getMock('\Magento\Framework\Model\Resource\Db\Context', [], [], '', false);
+ $contextMock->expects($this->once())->method('getResources')->willReturn($this->resourceMock);
+
$this->model = new \Magento\Weee\Model\Resource\Attribute\Backend\Weee\Tax(
- $this->resourceMock,
+ $contextMock,
$this->storeManagerMock
);
}
diff --git a/lib/internal/Magento/Framework/App/Resource.php b/lib/internal/Magento/Framework/App/Resource.php
index 2becb49921eb9..518f642c31680 100644
--- a/lib/internal/Magento/Framework/App/Resource.php
+++ b/lib/internal/Magento/Framework/App/Resource.php
@@ -90,6 +90,17 @@ public function __construct(
public function getConnection($resourceName)
{
$connectionName = $this->_config->getConnectionName($resourceName);
+ return $this->getConnectionByName($connectionName);
+ }
+
+ /**
+ * Retrieve connection by $connectionName
+ *
+ * @param string $connectionName
+ * @return bool|\Magento\Framework\DB\Adapter\AdapterInterface
+ */
+ public function getConnectionByName($connectionName)
+ {
if (isset($this->_connections[$connectionName])) {
return $this->_connections[$connectionName];
}
@@ -115,9 +126,10 @@ public function getConnection($resourceName)
* Get resource table name, validated by db adapter
*
* @param string|string[] $modelEntity
+ * @param string $connectionName
* @return string
*/
- public function getTableName($modelEntity)
+ public function getTableName($modelEntity, $connectionName = self::DEFAULT_READ_RESOURCE)
{
$tableSuffix = null;
if (is_array($modelEntity)) {
@@ -139,7 +151,7 @@ public function getTableName($modelEntity)
if ($tableSuffix) {
$tableName .= '_' . $tableSuffix;
}
- return $this->getConnection(self::DEFAULT_READ_RESOURCE)->getTableName($tableName);
+ return $this->getConnection($connectionName)->getTableName($tableName);
}
/**
diff --git a/lib/internal/Magento/Framework/App/Resource/Config.php b/lib/internal/Magento/Framework/App/Resource/Config.php
index edd93993a2849..381ad3e718605 100644
--- a/lib/internal/Magento/Framework/App/Resource/Config.php
+++ b/lib/internal/Magento/Framework/App/Resource/Config.php
@@ -24,19 +24,19 @@ class Config extends \Magento\Framework\Config\Data\Scoped implements ConfigInte
* @param Config\Reader $reader
* @param \Magento\Framework\Config\ScopeInterface $configScope
* @param \Magento\Framework\Config\CacheInterface $cache
+ * @param \Magento\Framework\App\DeploymentConfig $deploymentConfig
* @param string $cacheId
- * @param array $initialResources
* @throws \InvalidArgumentException
*/
public function __construct(
Config\Reader $reader,
\Magento\Framework\Config\ScopeInterface $configScope,
\Magento\Framework\Config\CacheInterface $cache,
- $cacheId = 'resourcesCache',
- $initialResources = []
+ \Magento\Framework\App\DeploymentConfig $deploymentConfig,
+ $cacheId = 'resourcesCache'
) {
parent::__construct($reader, $configScope, $cache, $cacheId);
- foreach ($initialResources as $resourceName => $resourceData) {
+ foreach ($deploymentConfig->getSegment('resource') as $resourceName => $resourceData) {
if (!isset($resourceData['connection'])) {
throw new \InvalidArgumentException('Invalid initial resource configuration');
}
@@ -64,6 +64,7 @@ public function getConnectionName($resourceName)
break;
} elseif (isset($this->_connectionNames[$pointerResourceName])) {
$this->_connectionNames[$resourceName] = $this->_connectionNames[$pointerResourceName];
+ $connectionName = $this->_connectionNames[$resourceName];
break;
} elseif (isset($resourcesConfig[$pointerResourceName]['extends'])) {
$pointerResourceName = $resourcesConfig[$pointerResourceName]['extends'];
diff --git a/lib/internal/Magento/Framework/Model/Resource/Db/AbstractDb.php b/lib/internal/Magento/Framework/Model/Resource/Db/AbstractDb.php
index a4578b8aa3fbd..7b7d8c3229bd3 100644
--- a/lib/internal/Magento/Framework/Model/Resource/Db/AbstractDb.php
+++ b/lib/internal/Magento/Framework/Model/Resource/Db/AbstractDb.php
@@ -12,6 +12,7 @@
/**
* Abstract resource model class
* @SuppressWarnings(PHPMD.NumberOfChildren)
+ * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
abstract class AbstractDb extends \Magento\Framework\Model\Resource\AbstractResource
{
@@ -116,14 +117,30 @@ abstract class AbstractDb extends \Magento\Framework\Model\Resource\AbstractReso
*/
protected $_serializableFields = [];
+ /**
+ * @var TransactionManagerInterface
+ */
+ protected $transactionManager;
+
+ /**
+ * @var ObjectRelationProcessor
+ */
+ protected $objectRelationProcessor;
+
/**
* Class constructor
*
- * @param \Magento\Framework\App\Resource $resource
+ * @param \Magento\Framework\Model\Resource\Db\Context $context
+ * @param string|null $resourcePrefix
*/
- public function __construct(\Magento\Framework\App\Resource $resource)
+ public function __construct(\Magento\Framework\Model\Resource\Db\Context $context, $resourcePrefix = null)
{
- $this->_resources = $resource;
+ $this->transactionManager = $context->getTransactionManager();
+ $this->_resources = $context->getResources();
+ $this->objectRelationProcessor = $context->getObjectRelationProcessor();
+ if (!is_null($resourcePrefix)) {
+ $this->_resourcePrefix = $resourcePrefix;
+ }
parent::__construct();
}
@@ -261,7 +278,8 @@ public function getTable($tableName)
}
if (!isset($this->_tables[$cacheName])) {
- $this->_tables[$cacheName] = $this->_resources->getTableName($tableName);
+ $connectionName = $this->_resourcePrefix . '_read';
+ $this->_tables[$cacheName] = $this->_resources->getTableName($tableName, $connectionName);
}
return $this->_tables[$cacheName];
}
@@ -392,6 +410,7 @@ public function save(\Magento\Framework\Model\AbstractModel $object)
$this->_serializeFields($object);
$this->_beforeSave($object);
$this->_checkUnique($object);
+ $this->objectRelationProcessor->validateDataIntegrity($this->getMainTable(), $object->getData());
if (!is_null($object->getId()) && (!$this->_useIsObjectNew || !$object->isObjectNew())) {
$condition = $this->_getWriteAdapter()->quoteInto($this->getIdFieldName() . '=?', $object->getId());
/**
@@ -455,25 +474,28 @@ public function save(\Magento\Framework\Model\AbstractModel $object)
*
* @param \Magento\Framework\Model\AbstractModel $object
* @return $this
+ * @throws \Exception
*/
public function delete(\Magento\Framework\Model\AbstractModel $object)
{
- $this->beginTransaction();
+ $connection = $this->transactionManager->start($this->_getWriteAdapter());
try {
$object->beforeDelete();
$this->_beforeDelete($object);
- $this->_getWriteAdapter()->delete(
+ $this->objectRelationProcessor->delete(
+ $this->transactionManager,
+ $connection,
$this->getMainTable(),
- $this->_getWriteAdapter()->quoteInto($this->getIdFieldName() . '=?', $object->getId())
+ $this->_getWriteAdapter()->quoteInto($this->getIdFieldName() . '=?', $object->getId()),
+ $object->getData()
);
$this->_afterDelete($object);
-
$object->isDeleted(true);
$object->afterDelete();
- $this->commit();
+ $this->transactionManager->commit();
$object->afterDeleteCommit();
} catch (\Exception $e) {
- $this->rollBack();
+ $this->transactionManager->rollBack();
throw $e;
}
return $this;
diff --git a/lib/internal/Magento/Framework/Model/Resource/Db/Context.php b/lib/internal/Magento/Framework/Model/Resource/Db/Context.php
new file mode 100644
index 0000000000000..916fefdec7966
--- /dev/null
+++ b/lib/internal/Magento/Framework/Model/Resource/Db/Context.php
@@ -0,0 +1,67 @@
+transactionManager = $transactionManager;
+ $this->resources = $resource;
+ $this->objectRelationProcessor = $objectRelationProcessor;
+ }
+
+ /**
+ * @return \Magento\Framework\App\Resource
+ */
+ public function getResources()
+ {
+ return $this->resources;
+ }
+
+ /**
+ * @return TransactionManagerInterface
+ */
+ public function getTransactionManager()
+ {
+ return $this->transactionManager;
+ }
+
+ /**
+ * @return ObjectRelationProcessor
+ */
+ public function getObjectRelationProcessor()
+ {
+ return $this->objectRelationProcessor;
+ }
+}
diff --git a/lib/internal/Magento/Framework/Model/Resource/Db/ObjectRelationProcessor.php b/lib/internal/Magento/Framework/Model/Resource/Db/ObjectRelationProcessor.php
new file mode 100644
index 0000000000000..5b3f620d9606b
--- /dev/null
+++ b/lib/internal/Magento/Framework/Model/Resource/Db/ObjectRelationProcessor.php
@@ -0,0 +1,47 @@
+delete($table, $condition);
+ }
+
+ /**
+ * Validate integrity of the given data
+ *
+ * @param string $table
+ * @param array $involvedData
+ * @return void
+ * @SuppressWarnings(PHPMD.UnusedFormalParameter)
+ */
+ public function validateDataIntegrity($table, array $involvedData)
+ {
+ return;
+ }
+}
diff --git a/lib/internal/Magento/Framework/Model/Resource/Db/TransactionManager.php b/lib/internal/Magento/Framework/Model/Resource/Db/TransactionManager.php
new file mode 100644
index 0000000000000..b25178ef0dc38
--- /dev/null
+++ b/lib/internal/Magento/Framework/Model/Resource/Db/TransactionManager.php
@@ -0,0 +1,60 @@
+participants[] = $connection;
+ $connection->beginTransaction();
+ return $connection;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function commit()
+ {
+ /** @var \Magento\Framework\DB\Adapter\AdapterInterface $connection */
+ while ($connection = array_pop($this->participants)) {
+ $connection->commit();
+ }
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function rollBack()
+ {
+ /** @var \Magento\Framework\DB\Adapter\AdapterInterface $connection */
+ while ($connection = array_pop($this->participants)) {
+ $connection->rollBack();
+ }
+ }
+
+ /**
+ * Get object key
+ *
+ * @param Connection $connection
+ * @return string
+ */
+ protected function getConnectionKey(Connection $connection)
+ {
+ return spl_object_hash($connection);
+ }
+}
diff --git a/lib/internal/Magento/Framework/Model/Resource/Db/TransactionManagerInterface.php b/lib/internal/Magento/Framework/Model/Resource/Db/TransactionManagerInterface.php
new file mode 100644
index 0000000000000..60dfc736f532e
--- /dev/null
+++ b/lib/internal/Magento/Framework/Model/Resource/Db/TransactionManagerInterface.php
@@ -0,0 +1,34 @@
+serviceLocator->get('Magento\Framework\Module\ModuleList'),
$this->serviceLocator->get('Magento\Setup\Module\Setup\FileResolver'),
$moduleName,
- $this->getResource()
+ new \Magento\Framework\Model\Resource\Db\Context(
+ $this->getResource(),
+ $this->serviceLocator->get('Magento\Framework\Model\Resource\Db\TransactionManager'),
+ $this->serviceLocator->get('Magento\Framework\Model\Resource\Db\ObjectRelationProcessor')
+ )
);
}
diff --git a/setup/src/Magento/Setup/Module/SetupModule.php b/setup/src/Magento/Setup/Module/SetupModule.php
index 1806578099ab8..b5a2ed82b7aca 100644
--- a/setup/src/Magento/Setup/Module/SetupModule.php
+++ b/setup/src/Magento/Setup/Module/SetupModule.php
@@ -57,8 +57,8 @@ class SetupModule extends Setup
* @param LoggerInterface $log
* @param ModuleListInterface $moduleList
* @param SetupFileResolver $fileResolver
- * @param string $moduleName
- * @param \Magento\Framework\App\Resource $resource
+ * @param $moduleName
+ * @param \Magento\Framework\Model\Resource\Db\Context $context
* @param string $connectionName
*/
public function __construct(
@@ -66,14 +66,14 @@ public function __construct(
ModuleListInterface $moduleList,
SetupFileResolver $fileResolver,
$moduleName,
- \Magento\Framework\App\Resource $resource,
+ \Magento\Framework\Model\Resource\Db\Context $context,
$connectionName = SetupInterface::DEFAULT_SETUP_CONNECTION
) {
- parent::__construct($resource, $connectionName);
+ parent::__construct($context->getResources(), $connectionName);
$this->logger = $log;
$this->fileResolver = $fileResolver;
$this->moduleConfig = $moduleList->getOne($moduleName);
- $this->resource = new Resource($resource);
+ $this->resource = new Resource($context);
$this->resourceName = $this->fileResolver->getResourceCode($moduleName);
}