36 lines
984 B
PHP
36 lines
984 B
PHP
<?php
|
|
|
|
namespace FOQ\ElasticaBundle\Command;
|
|
|
|
use Symfony\Bundle\FrameworkBundle\Command\Command as BaseCommand;
|
|
use Symfony\Component\Console\Input\InputArgument;
|
|
use Symfony\Component\Console\Input\InputOption;
|
|
use Symfony\Component\Console\Input\InputInterface;
|
|
use Symfony\Component\Console\Output\OutputInterface;
|
|
use Symfony\Component\Console\Output\Output;
|
|
|
|
class CreateIndexesCommand extends BaseCommand
|
|
{
|
|
/**
|
|
* @see Command
|
|
*/
|
|
protected function configure()
|
|
{
|
|
$this
|
|
->setName('foq:elastica:reset')
|
|
->setDescription('Recreates all indexes');
|
|
}
|
|
|
|
/**
|
|
* @see Command
|
|
*/
|
|
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();
|
|
}
|
|
}
|
|
}
|