objectManagerFactory = $objectManagerFactory; $this->collectionFactory = $collectionFactory; parent::__construct(); } /** * Return the array of all indexers with keys as indexer ids. * * @return IndexerInterface[] */ protected function getAllIndexers() { $indexers = $this->getCollectionFactory()->create()->getItems(); return array_combine( array_map( function ($item) { /** @var IndexerInterface $item */ return $item->getId(); }, $indexers ), $indexers ); } /** * Gets initialized object manager * * @return ObjectManagerInterface */ protected function getObjectManager() { if (null == $this->objectManager) { $area = FrontNameResolver::AREA_CODE; $this->objectManager = $this->objectManagerFactory->create($_SERVER); /** @var \Magento\Framework\App\State $appState */ $appState = $this->objectManager->get(\Magento\Framework\App\State::class); $appState->setAreaCode($area); $configLoader = $this->objectManager->get(\Magento\Framework\ObjectManager\ConfigLoaderInterface::class); $this->objectManager->configure($configLoader->load($area)); } return $this->objectManager; } /** * Get collection factory * * @return \Magento\Indexer\Model\Indexer\CollectionFactory * @deprecated 100.2.0 */ private function getCollectionFactory() { if (null === $this->collectionFactory) { $this->collectionFactory = $this->getObjectManager() ->get(\Magento\Indexer\Model\Indexer\CollectionFactory::class); } return $this->collectionFactory; } }