setName('foq:elastica:populate') ->setDescription('Populates search indexes from providers'); } /** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $output->writeln('Resetting indexes'); $this->getContainer()->get('foq_elastica.reseter')->reset(); $output->writeln('Populating indexes'); $this->getContainer()->get('foq_elastica.populator')->populate(function($text) use ($output) { $output->writeLn($text); }); $output->writeln('Refreshing indexes'); array_map(function($index) { $index->refresh(); }, $this->getContainer()->get('foq_elastica.index_manager')->getAllIndexes()); $output->writeln('Done'); } }