_dataObjectFactory = $dataObjectFactory; $this->scanner = $scanner; $this->backendSession = $backendSession; } /** * @return AggregationInterface */ public function getAggregations() { return $this->aggregations; } /** * @param AggregationInterface $aggregations * @return $this */ public function setAggregations($aggregations) { $this->aggregations = $aggregations; } /** * Retrieve all ids for collection * Backward compatibility with EAV collection * * @param int $limit * @param int $offset * @return array */ public function getAllIds($limit = null, $offset = null) { return $this->getConnection()->fetchCol($this->_getAllIdsSelect($limit, $offset), $this->_bindParams); } /** * Get search criteria. * * @return \Magento\Framework\Api\SearchCriteriaInterface|null */ public function getSearchCriteria() { return null; } /** * Set search criteria. * * @param \Magento\Framework\Api\SearchCriteriaInterface $searchCriteria * @return $this * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function setSearchCriteria(\Magento\Framework\Api\SearchCriteriaInterface $searchCriteria = null) { return $this; } /** * Get total count. * * @return int */ public function getTotalCount() { return $this->getSize(); } /** * Set total count. * * @param int $totalCount * @return $this * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function setTotalCount($totalCount) { return $this; } /** * Set items list. * * @param \Magento\Framework\Api\ExtensibleDataInterface[] $items * @return $this * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function setItems(array $items = null) { return $this; } /** * @return \Magento\Framework\DataObject[] */ public function getItems() { $this->_populateCollection(); return parent::getItems(); } public function _populateCollection() { $rewritesOption = $this->backendSession->getDebuggerRewite(false); $rewrites = $this->scanner->getRewrites($rewritesOption); $filterCondition = $this->scanner->getData('filterCondition') ?? ''; $searchKey = str_replace("\\\\\\\\", "\\", $filterCondition); if ($searchKey) { foreach ($rewrites as $key => $value) { if (strpos(strtolower($key), strtolower($searchKey)) === false) { unset($rewrites[$key]); } } } foreach ($rewrites as $originalClass => $rewriteOptions) { foreach ($rewriteOptions as $areaCode => $rewriteClasses) { if (count($rewriteClasses) > 1) { $status = false; } else { $status = true; } /** * Exceptions * Magento\Catalog\Block\Product\ImageBuilder class we rewrite in LazyLoading, OwlCarousel modules as well * these modules are sold as standalone ones, so we rewrite the class also in CategoryPage module * where we merge the functionalities from those 2 modules, in this case this rewrite is marked as Ok, */ if (($originalClass == 'Magento\Catalog\Block\Product\ImageFactory') && ($areaCode == 'frontend') ) { $checkRewriteStatus = true; foreach ($rewriteClasses as $className) { if (strpos($className, 'WeltPixel\\') === false ) { $checkRewriteStatus = false; } } $status = $checkRewriteStatus; } foreach ($rewriteClasses as $key => $rewriteClass) { $item = $this->_dataObjectFactory->create(); if ($key) { $item->setArea(''); $item->setOriginalClass(''); } else { $item->setArea($areaCode); $item->setOriginalClass($originalClass); } $item->setRewriteClass($rewriteClass); $item->setStatus($status); $this->addItem($item); } } } } /** * Filter applied only on the original_class column * * @param array|string $field * @param array|int|string $condition * @return $this */ public function addFieldToFilter($field, $condition) { $conditionValue = substr($condition['like'], 2, -2); $this->scanner->setData('filterCondition', $conditionValue); return $this; } }