示例#1
0
 /**
  * Regenerate indexes for all indexers
  *
  * @return void
  */
 public function reindexAll()
 {
     /** @var IndexerInterface[] $indexers */
     $indexers = $this->indexersFactory->create()->getItems();
     foreach ($indexers as $indexer) {
         $indexer->reindexAll();
     }
 }
示例#2
0
 /**
  * Parses string with indexers and return array of indexer instances
  *
  * @param string $string
  * @return IndexerInterface[]
  */
 protected function parseIndexerString($string)
 {
     $indexers = [];
     if ($string == 'all') {
         /** @var Indexer[] $indexers */
         $indexers = $this->indexersFactory->create()->getItems();
     } elseif (!empty($string)) {
         $codes = explode(',', $string);
         foreach ($codes as $code) {
             $indexer = $this->indexerFactory->create();
             try {
                 $indexer->load($code);
                 $indexers[] = $indexer;
             } catch (\Exception $e) {
                 echo 'Warning: Unknown indexer with code ' . trim($code) . PHP_EOL;
                 $this->hasErrors = true;
             }
         }
     }
     return $indexers;
 }