commit
cae2ebf20f
|
@ -81,7 +81,7 @@ abstract class AbstractElasticaToModelTransformer implements ElasticaToModelTran
|
|||
* @param string $class the model class
|
||||
* @param string $identifierField like 'id'
|
||||
* @param array $identifierValues ids values
|
||||
* @param mixed $hydrate whether or not to hydrate the objects, false returns arrays
|
||||
* @param Boolean $hydrate whether or not to hydrate the objects, false returns arrays
|
||||
* @return array of objects or arrays
|
||||
*/
|
||||
protected abstract function findByIdentifiers($class, $identifierField, array $identifierValues, $hydrate);
|
||||
|
|
|
@ -18,7 +18,7 @@ class ElasticaToModelTransformer extends AbstractElasticaToModelTransformer
|
|||
* @param string $class the model class
|
||||
* @param string $identifierField like 'id'
|
||||
* @param array $identifierValues ids values
|
||||
* @param mixed $hydrate whether or not to hydrate the objects, false returns arrays
|
||||
* @param Boolean $hydrate whether or not to hydrate the objects, false returns arrays
|
||||
* @return array of objects or arrays
|
||||
*/
|
||||
protected function findByIdentifiers($class, $identifierField, array $identifierValues, $hydrate)
|
||||
|
|
|
@ -2,7 +2,9 @@
|
|||
|
||||
namespace FOQ\ElasticaBundle\Doctrine\ORM;
|
||||
|
||||
use FOQ\ElasticaBundle\Doctrine\AbstractElasticaToModelTransformer;
|
||||
use Elastica_Document;
|
||||
use Doctrine\ORM\Query;
|
||||
|
||||
/**
|
||||
* Maps Elastica documents with Doctrine objects
|
||||
|
@ -17,11 +19,17 @@ class ElasticaToModelTransformer extends AbstractElasticaToModelTransformer
|
|||
* @param string $class the model class
|
||||
* @param string $identifierField like 'id'
|
||||
* @param array $identifierValues ids values
|
||||
* @param mixed $hydrate whether or not to hydrate the objects, false returns arrays
|
||||
* @param Boolean $hydrate whether or not to hydrate the objects, false returns arrays
|
||||
* @return array of objects or arrays
|
||||
*/
|
||||
protected function findByIdentifiers($class, $identifierField, array $identifierValues, $hydrate)
|
||||
{
|
||||
throw new \Exception('Not implemented yet. Implement me! See ElasticaToModelDoctrineMongoDBTransformer as an example.');
|
||||
$hydratationMode = $hydrate ? Query::HYDRATE_OBJECT : Query::HYDRATE_ARRAY;
|
||||
$qb = $this->objectManager
|
||||
->getRepository($class)
|
||||
->createQueryBuilder('o');
|
||||
$qb->where($qb->expr()->in('o.'.$identifierField, $identifierValues));
|
||||
|
||||
return $qb->getQuery()->setHydrationMode($hydrationMode)->execute();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue