2011-04-12 04:27:47 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace FOQ\ElasticaBundle\Command;
|
|
|
|
|
2011-06-21 19:23:25 +02:00
|
|
|
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
|
2011-04-12 04:27:47 +02:00
|
|
|
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;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Populate the search index
|
|
|
|
*/
|
2011-06-21 19:23:25 +02:00
|
|
|
class PopulateCommand extends ContainerAwareCommand
|
2011-04-12 04:27:47 +02:00
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @see Command
|
|
|
|
*/
|
|
|
|
protected function configure()
|
|
|
|
{
|
|
|
|
$this
|
|
|
|
->setName('foq:elastica:populate')
|
|
|
|
->setDescription('Populates search indexes from providers');
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* {@inheritdoc}
|
|
|
|
*/
|
|
|
|
protected function execute(InputInterface $input, OutputInterface $output)
|
|
|
|
{
|
2012-03-02 06:28:38 +01:00
|
|
|
$output->writeln('Resetting indexes');
|
|
|
|
$this->getContainer()->get('foq_elastica.resetter')->reset();
|
2011-04-12 04:27:47 +02:00
|
|
|
|
2011-04-14 01:22:50 +02:00
|
|
|
$output->writeln('Populating indexes');
|
2011-06-21 19:23:25 +02:00
|
|
|
$this->getContainer()->get('foq_elastica.populator')->populate(function($text) use ($output) {
|
2011-04-15 21:19:27 +02:00
|
|
|
$output->writeLn($text);
|
|
|
|
});
|
2011-04-12 04:27:47 +02:00
|
|
|
|
2011-09-12 18:28:59 +02:00
|
|
|
$output->writeln('Refreshing indexes');
|
|
|
|
array_map(function($index) {
|
|
|
|
$index->refresh();
|
|
|
|
}, $this->getContainer()->get('foq_elastica.index_manager')->getAllIndexes());
|
|
|
|
|
2011-04-12 04:27:47 +02:00
|
|
|
$output->writeln('Done');
|
|
|
|
}
|
|
|
|
}
|