10 use Symfony\Component\Console\Command\Command;
22 private $objectManagerFactory;
27 private $objectManager;
32 private $collectionFactory;
42 \
Magento\Indexer\Model\Indexer\CollectionFactory $collectionFactory =
null 45 $this->collectionFactory = $collectionFactory;
46 parent::__construct();
54 protected function getAllIndexers()
56 $indexers = $this->getCollectionFactory()->create()->getItems();
61 return $item->getId();
74 protected function getObjectManager()
76 if (
null == $this->objectManager) {
78 $this->objectManager = $this->objectManagerFactory->create($_SERVER);
80 $appState = $this->objectManager->get(\
Magento\Framework\
App\State::class);
81 $appState->setAreaCode($area);
82 $configLoader = $this->objectManager->get(\
Magento\Framework\ObjectManager\ConfigLoaderInterface::class);
83 $this->objectManager->configure($configLoader->load($area));
85 return $this->objectManager;
94 private function getCollectionFactory()
96 if (
null === $this->collectionFactory) {
97 $this->collectionFactory = $this->getObjectManager()
98 ->get(\
Magento\Indexer\Model\Indexer\CollectionFactory::class);
100 return $this->collectionFactory;
__construct(ObjectManagerFactory $objectManagerFactory, \Magento\Indexer\Model\Indexer\CollectionFactory $collectionFactory=null)