Skip to content

Commit

Permalink
ENGCOM-3502: Introduce resource model pool to replace UniversalFactory
Browse files Browse the repository at this point in the history
  • Loading branch information
sivaschenko authored Feb 16, 2019
2 parents 77251ff + b3cea0e commit 3e35044
Show file tree
Hide file tree
Showing 28 changed files with 579 additions and 367 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

use Magento\CatalogUrlRewrite\Model\CategoryUrlRewriteGenerator;
use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Framework\Model\ResourceModel\ResourceModelPoolInterface;
use Magento\Store\Model\ScopeInterface;

/**
Expand Down Expand Up @@ -83,6 +84,7 @@ class Collection extends \Magento\Catalog\Model\ResourceModel\Collection\Abstrac
* @param \Magento\Framework\DB\Adapter\AdapterInterface $connection
* @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
*
* @param ResourceModelPoolInterface|null $resourceModelPool
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
public function __construct(
Expand All @@ -97,7 +99,8 @@ public function __construct(
\Magento\Framework\Validator\UniversalFactory $universalFactory,
\Magento\Store\Model\StoreManagerInterface $storeManager,
\Magento\Framework\DB\Adapter\AdapterInterface $connection = null,
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig = null
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig = null,
ResourceModelPoolInterface $resourceModelPool = null
) {
parent::__construct(
$entityFactory,
Expand All @@ -110,7 +113,8 @@ public function __construct(
$resourceHelper,
$universalFactory,
$storeManager,
$connection
$connection,
$resourceModelPool
);
$this->scopeConfig = $scopeConfig ?:
\Magento\Framework\App\ObjectManager::getInstance()->get(ScopeConfigInterface::class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@
*/
namespace Magento\Catalog\Model\ResourceModel\Collection;

use Magento\Framework\Model\ResourceModel\ResourceModelPoolInterface;

/**
* Catalog EAV collection resource abstract model
*
* Implement using different stores for retrieve attribute values
*
* @api
Expand Down Expand Up @@ -43,6 +46,7 @@ class AbstractCollection extends \Magento\Eav\Model\Entity\Collection\AbstractCo
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
* @param \Magento\Framework\DB\Adapter\AdapterInterface $connection
*
* @param ResourceModelPoolInterface|null $resourceModelPool
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
public function __construct(
Expand All @@ -56,7 +60,8 @@ public function __construct(
\Magento\Eav\Model\ResourceModel\Helper $resourceHelper,
\Magento\Framework\Validator\UniversalFactory $universalFactory,
\Magento\Store\Model\StoreManagerInterface $storeManager,
\Magento\Framework\DB\Adapter\AdapterInterface $connection = null
\Magento\Framework\DB\Adapter\AdapterInterface $connection = null,
ResourceModelPoolInterface $resourceModelPool = null
) {
$this->_storeManager = $storeManager;
parent::__construct(
Expand All @@ -69,7 +74,8 @@ public function __construct(
$eavEntityFactory,
$resourceHelper,
$universalFactory,
$connection
$connection,
$resourceModelPool
);
}

Expand Down Expand Up @@ -205,10 +211,7 @@ protected function _getLoadAttributesSelect($table, $attributeIds = [])
}

/**
* @param \Magento\Framework\DB\Select $select
* @param string $table
* @param string $type
* @return \Magento\Framework\DB\Select
* @inheritdoc
*/
protected function _addLoadAttributesSelectValues($select, $table, $type)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
use Magento\Store\Model\Store;
use Magento\Catalog\Model\Indexer\Category\Product\TableMaintainer;
use Magento\Framework\Indexer\DimensionFactory;
use Magento\Framework\Model\ResourceModel\ResourceModelPoolInterface;

/**
* Product collection
Expand Down Expand Up @@ -297,6 +298,7 @@ class Collection extends \Magento\Catalog\Model\ResourceModel\Collection\Abstrac

/**
* Collection constructor
*
* @param \Magento\Framework\Data\Collection\EntityFactory $entityFactory
* @param \Psr\Log\LoggerInterface $logger
* @param \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy
Expand All @@ -322,6 +324,8 @@ class Collection extends \Magento\Catalog\Model\ResourceModel\Collection\Abstrac
* @param TableMaintainer|null $tableMaintainer
* @param PriceTableResolver|null $priceTableResolver
* @param DimensionFactory|null $dimensionFactory
* @param ResourceModelPoolInterface|null $resourceModelPool
*
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
public function __construct(
Expand Down Expand Up @@ -349,7 +353,8 @@ public function __construct(
MetadataPool $metadataPool = null,
TableMaintainer $tableMaintainer = null,
PriceTableResolver $priceTableResolver = null,
DimensionFactory $dimensionFactory = null
DimensionFactory $dimensionFactory = null,
ResourceModelPoolInterface $resourceModelPool = null
) {
$this->moduleManager = $moduleManager;
$this->_catalogProductFlatState = $catalogProductFlatState;
Expand Down Expand Up @@ -377,7 +382,8 @@ public function __construct(
$resourceHelper,
$universalFactory,
$storeManager,
$connection
$connection,
$resourceModelPool
);
$this->tableMaintainer = $tableMaintainer ?: ObjectManager::getInstance()->get(TableMaintainer::class);
$this->priceTableResolver = $priceTableResolver ?: ObjectManager::getInstance()->get(PriceTableResolver::class);
Expand Down Expand Up @@ -1437,7 +1443,7 @@ protected function _addUrlRewrite()
'u.url_rewrite_id=cu.url_rewrite_id'
)->where('cu.url_rewrite_id IS NULL');
}

// more priority is data with category id
$urlRewrites = [];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@
*/
namespace Magento\Catalog\Model\ResourceModel\Product\Compare\Item;

use Magento\Catalog\Model\Indexer\Category\Product\TableMaintainer;
use Magento\Catalog\Model\Indexer\Product\Price\PriceTableResolver;
use Magento\Catalog\Model\ResourceModel\Product\Collection\ProductLimitationFactory;
use Magento\Framework\EntityManager\MetadataPool;
use Magento\Framework\Indexer\DimensionFactory;
use Magento\Framework\Model\ResourceModel\ResourceModelPoolInterface;

/**
* Catalog Product Compare Items Resource Collection
*
Expand Down Expand Up @@ -75,7 +82,12 @@ class Collection extends \Magento\Catalog\Model\ResourceModel\Product\Collection
* @param \Magento\Catalog\Model\ResourceModel\Product\Compare\Item $catalogProductCompareItem
* @param \Magento\Catalog\Helper\Product\Compare $catalogProductCompare
* @param \Magento\Framework\DB\Adapter\AdapterInterface $connection
*
* @param ProductLimitationFactory|null $productLimitationFactory
* @param MetadataPool|null $metadataPool
* @param TableMaintainer|null $tableMaintainer
* @param PriceTableResolver|null $priceTableResolver
* @param DimensionFactory|null $dimensionFactory
* @param ResourceModelPoolInterface|null $resourceModelPool
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
public function __construct(
Expand All @@ -100,7 +112,13 @@ public function __construct(
\Magento\Customer\Api\GroupManagementInterface $groupManagement,
\Magento\Catalog\Model\ResourceModel\Product\Compare\Item $catalogProductCompareItem,
\Magento\Catalog\Helper\Product\Compare $catalogProductCompare,
\Magento\Framework\DB\Adapter\AdapterInterface $connection = null
\Magento\Framework\DB\Adapter\AdapterInterface $connection = null,
ProductLimitationFactory $productLimitationFactory = null,
MetadataPool $metadataPool = null,
TableMaintainer $tableMaintainer = null,
PriceTableResolver $priceTableResolver = null,
DimensionFactory $dimensionFactory = null,
ResourceModelPoolInterface $resourceModelPool = null
) {
$this->_catalogProductCompareItem = $catalogProductCompareItem;
$this->_catalogProductCompare = $catalogProductCompare;
Expand All @@ -124,7 +142,13 @@ public function __construct(
$customerSession,
$dateTime,
$groupManagement,
$connection
$connection,
$productLimitationFactory,
$metadataPool,
$tableMaintainer,
$priceTableResolver,
$dimensionFactory,
$resourceModelPool
);
}

Expand Down Expand Up @@ -403,6 +427,7 @@ public function clear()

/**
* Retrieve is flat enabled flag
*
* Overwrite disable flat for compared item if required EAV resource
*
* @return bool
Expand Down
Loading

0 comments on commit 3e35044

Please sign in to comment.