for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace GBProd\ElasticsearchDataProviderBundle\DataProvider;
use Elasticsearch\Client;
use GBProd\ElasticsearchDataProviderBundle\Event\HasIndexedDocument;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
/**
* Abstract class for data providing
*
* @author gbprod <[email protected]>
*/
abstract class DataProvider implements DataProviderInterface
{
* @var Client
private $client;
* @var string
private $index;
private $type;
* @var EventDispatcherInterface
private $dispatcher;
* {@inheritdoc}
public function run(
Client $client,
$index,
$type,
EventDispatcherInterface $dispatcher
) {
$this->client = $client;
$this->index = $index;
$this->type = $type;
$this->dispatcher = $dispatcher;
$this->populate();
}
* Populate
* @return null
abstract protected function populate();
* Index document
* @param string $id
* @param array $body
public function index($id, array $body)
$this->client->index([
'index' => $this->index,
'type' => $this->type,
'id' => $id,
'body' => $body,
]);
$this->dispatcher->dispatch(
'elasticsearch.has_indexed_document',
new HasIndexedDocument($id)
);
public function count()
return null;