Implement populator and add corresponding command
This commit is contained in:
parent
c56f4e62f5
commit
02dd4d85cc
39
Command/PopulateCommand.php
Normal file
39
Command/PopulateCommand.php
Normal file
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
|
||||
namespace FOQ\ElasticaBundle\Command;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Command\Command;
|
||||
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
|
||||
*/
|
||||
class PopulateCommand extends Command
|
||||
{
|
||||
/**
|
||||
* @see Command
|
||||
*/
|
||||
protected function configure()
|
||||
{
|
||||
$this
|
||||
->setName('foq:elastica:populate')
|
||||
->setDescription('Populates search indexes from providers');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$output->writeln('Populating indexes');
|
||||
|
||||
$populator = $this->container->get('foq_elastica.populator');
|
||||
$populator->populate();
|
||||
|
||||
$output->writeln('Done');
|
||||
}
|
||||
}
|
20
Populator.php
Normal file
20
Populator.php
Normal file
|
@ -0,0 +1,20 @@
|
|||
<?php
|
||||
|
||||
namespace FOQ\ElasticaBundle;
|
||||
|
||||
class Populator
|
||||
{
|
||||
protected $providers;
|
||||
|
||||
public function __construct(array $providers)
|
||||
{
|
||||
$this->providers = $providers;
|
||||
}
|
||||
|
||||
public function populate()
|
||||
{
|
||||
foreach ($this->providers as $provider) {
|
||||
$provider->populate();
|
||||
}
|
||||
}
|
||||
}
|
8
ProviderInterface.php
Normal file
8
ProviderInterface.php
Normal file
|
@ -0,0 +1,8 @@
|
|||
<?php
|
||||
|
||||
namespace FOQ\ElasticaBundle;
|
||||
|
||||
interface ProviderInterface
|
||||
{
|
||||
function populate();
|
||||
}
|
Loading…
Reference in a new issue