diff --git a/Command/CreateIndexesCommand.php b/Command/ResetCommand.php similarity index 70% rename from Command/CreateIndexesCommand.php rename to Command/ResetCommand.php index 6aa534f..0334d8b 100644 --- a/Command/CreateIndexesCommand.php +++ b/Command/ResetCommand.php @@ -9,7 +9,7 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Output\Output; -class CreateIndexesCommand extends BaseCommand +class ResetCommand extends BaseCommand { /** * @see Command @@ -26,10 +26,10 @@ class CreateIndexesCommand extends BaseCommand */ protected function execute(InputInterface $input, OutputInterface $output) { - foreach ($this->container->get('foq_elastica.index_manager')->getAllIndexes() as $name => $index) { - $output->writeLn(sprintf('Reset index "%s"', $name)); - $index->delete(); - $index->create(); - } + $output->writeLn('Reset all indexes'); + + $this->container->get('foq_elastica.reseter')->reset(); + + $output->writeln('Done'); } } diff --git a/Reseter.php b/Reseter.php new file mode 100644 index 0000000..18f2a46 --- /dev/null +++ b/Reseter.php @@ -0,0 +1,29 @@ +indexManager = $indexManager; + } + + /** + * Resets all indexes + * + * @return null + **/ + public function reset() + { + foreach ($this->indexManager->getAllIndexes() as $index) { + $index->delete(); + $index->create(); + } + } +} diff --git a/Resources/config/config.xml b/Resources/config/config.xml index 70ae1c1..b70cb06 100644 --- a/Resources/config/config.xml +++ b/Resources/config/config.xml @@ -13,10 +13,14 @@ + + + +