Permalink
Find file
Fetching contributors…
Cannot retrieve contributors at this time
executable file 33 lines (26 sloc) 754 Bytes
<?php
namespace FOQ\ElasticaBundle;
use FOQ\ElasticaBundle\Provider\ProviderInterface;
use Closure;
class Populator
{
protected $providers;
public function __construct(array $providers)
{
foreach ($providers as $name => $provider) {
$this->addProvider($name, $provider);
}
}
public function addProvider($name, ProviderInterface $provider)
{
$this->providers[$name] = $provider;
}
public function populate(Closure $loggerClosure)
{
foreach ($this->providers as $name => $provider) {
$provider->populate(function($text) use ($name, $loggerClosure) {
$loggerClosure(sprintf('Indexing %s, %s', $name, $text));
});
}
}
}