Newscoop\Tools\Console\Command\UpdateIndexCommand::execute PHP Method

execute() protected method

See also: Console\Command\Command
protected execute ( Symfony\Component\Console\Input\InputInterface $input, Symfony\Component\Console\Output\OutputInterface $output )
$input Symfony\Component\Console\Input\InputInterface
$output Symfony\Component\Console\Output\OutputInterface
    protected function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output)
    {
        // This is needed to surpress STRICT errors, else everything will FAIL :'(
        error_reporting(E_ALL & ~E_DEPRECATED & ~E_NOTICE & ~E_STRICT);
        global $g_ado_db;
        $container = $this->getApplication()->getKernel()->getContainer();
        $g_ado_db = $container->get('doctrine.adodb');
        $type = $input->getArgument('type');
        $indexers = $this->getIndexers();
        if ($type !== 'all' && !array_key_exists($type, $indexers)) {
            $output->writeln(sprintf('<error>Invalid value for parameter type specified.</error> Valid values are: all, %s', implode(', ', array_keys($indexers))));
        } else {
            $output->writeln('Indexing started.');
            if ($type === 'all') {
                foreach ($indexers as $name => $indexer) {
                    $indexer->update($input->getArgument('limit'));
                }
            } else {
                $indexers[$type]->update($input->getArgument('limit'));
            }
            $output->writeln('Indexer is done.');
        }
    }
UpdateIndexCommand