예제 #1
0
 /**
  * @see Symfony\Component\Console\Command\Command::execute()
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $index = $input->getOption('index');
     $type = $input->getOption('type');
     $force = (bool) $input->getOption('force');
     if (null === $index && null !== $type) {
         throw new \InvalidArgumentException('Cannot specify type option without an index.');
     }
     if (null !== $type) {
         $output->writeln(sprintf('<info>Resetting</info> <comment>%s/%s</comment>', $index, $type));
         $this->resetter->resetIndexType($index, $type);
     } else {
         $indexes = null === $index ? array_keys($this->indexManager->getAllIndexes()) : array($index);
         foreach ($indexes as $index) {
             $output->writeln(sprintf('<info>Resetting</info> <comment>%s</comment>', $index));
             $this->resetter->resetIndex($index, false, $force);
         }
     }
 }
 /**
  * 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, $reset);
 }
예제 #3
0
 /**
  * @expectedException \InvalidArgumentException
  */
 public function testResetIndexShouldThrowExceptionForInvalidIndex()
 {
     $resetter = new Resetter($this->indexConfigsByName);
     $resetter->resetIndex('baz');
 }
예제 #4
0
 /**
  * @expectedException \InvalidArgumentException
  */
 public function testFailureWhenMissingIndexDoesntDispatch()
 {
     $this->configManager->expects($this->once())->method('getIndexConfiguration')->with('nonExistant')->will($this->throwException(new \InvalidArgumentException()));
     $this->indexManager->expects($this->never())->method('getIndex');
     $this->resetter->resetIndex('nonExistant');
 }