Skip to content

Commit 2da0d9d

Browse files
committed
Avoid use of Object Manager
1 parent 5b5a194 commit 2da0d9d

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

app/code/Magento/Indexer/Controller/Adminhtml/Indexer/MassInvalidate.php

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,27 @@
55
*/
66
namespace Magento\Indexer\Controller\Adminhtml\Indexer;
77

8+
use Magento\Backend\App\Action\Context;
89
use Magento\Framework\App\Action\HttpPostActionInterface as HttpPostActionInterface;
10+
use Magento\Framework\Indexer\IndexerRegistry;
911

1012
/**
1113
* Controller endpoint for mass action: invalidate index
1214
*/
1315
class MassInvalidate extends \Magento\Indexer\Controller\Adminhtml\Indexer implements HttpPostActionInterface
1416
{
17+
/**
18+
* @param Context $context
19+
* @param IndexerRegistry $indexerRegistry
20+
*/
21+
public function __construct(
22+
Context $context,
23+
IndexerRegistry $indexerRegistry
24+
) {
25+
parent::__construct($context);
26+
$this->indexerRegistry = $indexerRegistry;
27+
}
28+
1529
/**
1630
* Turn mview on for the given indexers
1731
*
@@ -26,9 +40,7 @@ public function execute()
2640
try {
2741
foreach ($indexerIds as $indexerId) {
2842
/** @var \Magento\Framework\Indexer\IndexerInterface $model */
29-
$model = $this->_objectManager->get(
30-
\Magento\Framework\Indexer\IndexerRegistry::class
31-
)->get($indexerId);
43+
$model = $this->indexerRegistry->get($indexerId);
3244
$model->invalidate();
3345
}
3446
$this->messageManager->addSuccess(

0 commit comments

Comments
 (0)