|
6 | 6 |
|
7 | 7 | namespace Magento\Framework\Model\ResourceModel\Db\Collection;
|
8 | 8 |
|
9 |
| -use \Magento\Framework\App\ResourceConnection\SourceProviderInterface; |
10 |
| -use \Magento\Framework\Data\Collection\AbstractDb; |
| 9 | +use Magento\Framework\App\ObjectManager; |
| 10 | +use Magento\Framework\App\ResourceConnection\SourceProviderInterface; |
| 11 | +use Magento\Framework\Data\Collection\AbstractDb; |
| 12 | +use Magento\Framework\Event\ManagerInterface; |
11 | 13 |
|
12 | 14 | /**
|
13 | 15 | * Abstract Resource Collection
|
@@ -106,23 +108,23 @@ abstract class AbstractCollection extends AbstractDb implements SourceProviderIn
|
106 | 108 | /**
|
107 | 109 | * Event manager proxy
|
108 | 110 | *
|
109 |
| - * @var \Magento\Framework\Event\ManagerInterface |
| 111 | + * @var ManagerInterface |
110 | 112 | */
|
111 | 113 | protected $_eventManager = null;
|
112 | 114 |
|
113 | 115 | /**
|
114 | 116 | * @param \Magento\Framework\Data\Collection\EntityFactoryInterface $entityFactory
|
115 | 117 | * @param \Psr\Log\LoggerInterface $logger
|
116 | 118 | * @param \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy
|
117 |
| - * @param \Magento\Framework\Event\ManagerInterface $eventManager |
| 119 | + * @param ManagerInterface $eventManager |
118 | 120 | * @param \Magento\Framework\DB\Adapter\AdapterInterface $connection
|
119 | 121 | * @param \Magento\Framework\Model\ResourceModel\Db\AbstractDb $resource
|
120 | 122 | */
|
121 | 123 | public function __construct(
|
122 | 124 | \Magento\Framework\Data\Collection\EntityFactoryInterface $entityFactory,
|
123 | 125 | \Psr\Log\LoggerInterface $logger,
|
124 | 126 | \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy,
|
125 |
| - \Magento\Framework\Event\ManagerInterface $eventManager, |
| 127 | + ManagerInterface $eventManager, |
126 | 128 | \Magento\Framework\DB\Adapter\AdapterInterface $connection = null,
|
127 | 129 | \Magento\Framework\Model\ResourceModel\Db\AbstractDb $resource = null
|
128 | 130 | ) {
|
@@ -241,12 +243,7 @@ protected function _initSelectFields()
|
241 | 243 | $column = $field;
|
242 | 244 | }
|
243 | 245 |
|
244 |
| - if ($alias !== null && |
245 |
| - in_array($alias, $columnsToSelect) || |
246 |
| - // If field already joined from another table |
247 |
| - $alias === null && |
248 |
| - isset($alias, $columnsToSelect) |
249 |
| - ) { |
| 246 | + if ($alias !== null && in_array($alias, $columnsToSelect)) { |
250 | 247 | continue;
|
251 | 248 | }
|
252 | 249 |
|
@@ -468,9 +465,8 @@ public function getResourceModelName()
|
468 | 465 | public function getResource()
|
469 | 466 | {
|
470 | 467 | if (empty($this->_resource)) {
|
471 |
| - $this->_resource = \Magento\Framework\App\ObjectManager::getInstance()->create( |
472 |
| - $this->getResourceModelName() |
473 |
| - ); |
| 468 | + // phpcs:ignore Magento2.PHP.AutogeneratedClassNotInConstructor |
| 469 | + $this->_resource = ObjectManager::getInstance()->create($this->getResourceModelName()); |
474 | 470 | }
|
475 | 471 | return $this->_resource;
|
476 | 472 | }
|
@@ -513,14 +509,13 @@ public function getAllIds()
|
513 | 509 | */
|
514 | 510 | public function join($table, $cond, $cols = '*')
|
515 | 511 | {
|
| 512 | + $alias = $table; |
516 | 513 | if (is_array($table)) {
|
517 | 514 | foreach ($table as $k => $v) {
|
518 | 515 | $alias = $k;
|
519 | 516 | $table = $v;
|
520 | 517 | break;
|
521 | 518 | }
|
522 |
| - } else { |
523 |
| - $alias = $table; |
524 | 519 | }
|
525 | 520 |
|
526 | 521 | if (!isset($this->_joinedTables[$alias])) {
|
@@ -624,7 +619,7 @@ public function __sleep()
|
624 | 619 | public function __wakeup()
|
625 | 620 | {
|
626 | 621 | parent::__wakeup();
|
627 |
| - $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); |
628 |
| - $this->_eventManager = $objectManager->get(\Magento\Framework\Event\ManagerInterface::class); |
| 622 | + // phpcs:ignore Magento2.PHP.AutogeneratedClassNotInConstructor |
| 623 | + $this->_eventManager = ObjectManager::getInstance()->get(ManagerInterface::class); |
629 | 624 | }
|
630 | 625 | }
|
0 commit comments