Пример #1
0
 /**
  * Recreates an index, populates its types, and refreshes the index.
  *
  * @param OutputInterface $output
  * @param string          $index
  * @param boolean         $reset
  * @param array           $options
  */
 private function populateIndex(OutputInterface $output, $index, $reset, $options)
 {
     $event = new IndexPopulateEvent($index, $reset, $options);
     $this->dispatcher->dispatch(IndexPopulateEvent::PRE_INDEX_POPULATE, $event);
     if ($event->isReset()) {
         $output->writeln(sprintf('<info>Resetting</info> <comment>%s</comment>', $index));
         $this->resetter->resetIndex($index, true);
     }
     $types = array_keys($this->providerRegistry->getIndexProviders($index));
     foreach ($types as $type) {
         $this->populateIndexType($output, $index, $type, false, $event->getOptions());
     }
     $this->dispatcher->dispatch(IndexPopulateEvent::POST_INDEX_POPULATE, $event);
     $this->refreshIndex($output, $index);
 }
 /**
  * Recreates an index, populates its types, and refreshes the index.
  *
  * @param OutputInterface $output
  * @param string          $index
  * @param boolean         $reset
  * @param array           $options
  */
 private function populateIndex(OutputInterface $output, $index, $reset, $options)
 {
     if ($reset && $this->indexManager->getIndex($index)->exists()) {
         $output->writeln(sprintf('<info>Resetting</info> <comment>%s</comment>', $index));
         $this->resetter->resetIndex($index);
     }
     /** @var $providers ProviderInterface[] */
     $providers = $this->providerRegistry->getIndexProviders($index);
     foreach ($providers as $type => $provider) {
         $loggerClosure = function ($message) use($output, $index, $type) {
             $output->writeln(sprintf('<info>Populating</info> %s/%s, %s', $index, $type, $message));
         };
         $provider->populate($loggerClosure, $options);
     }
     $output->writeln(sprintf('<info>Refreshing</info> <comment>%s</comment>', $index));
     $this->indexManager->getIndex($index)->refresh();
 }