2011-05-10 00:06:55 +02:00
|
|
|
<?php
|
|
|
|
|
2013-03-27 18:44:06 +01:00
|
|
|
namespace FOS\ElasticaBundle\Doctrine\MongoDB;
|
2011-05-10 00:06:55 +02:00
|
|
|
|
2013-03-27 18:44:06 +01:00
|
|
|
use FOS\ElasticaBundle\Doctrine\AbstractElasticaToModelTransformer;
|
2011-05-10 00:06:55 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Maps Elastica documents with Doctrine objects
|
|
|
|
* This mapper assumes an exact match between
|
2015-03-12 11:20:00 +01:00
|
|
|
* elastica documents ids and doctrine object ids.
|
2011-05-10 00:06:55 +02:00
|
|
|
*/
|
2011-05-10 00:31:20 +02:00
|
|
|
class ElasticaToModelTransformer extends AbstractElasticaToModelTransformer
|
2011-05-10 00:06:55 +02:00
|
|
|
{
|
|
|
|
/**
|
2015-03-12 11:20:00 +01:00
|
|
|
* Fetch objects for theses identifier values.
|
|
|
|
*
|
|
|
|
* @param array $identifierValues ids values
|
|
|
|
* @param Boolean $hydrate whether or not to hydrate the objects, false returns arrays
|
2011-05-10 00:06:55 +02:00
|
|
|
*
|
|
|
|
* @return array of objects or arrays
|
|
|
|
*/
|
2012-07-10 22:28:31 +02:00
|
|
|
protected function findByIdentifiers(array $identifierValues, $hydrate)
|
2011-05-10 00:06:55 +02:00
|
|
|
{
|
2011-12-13 11:22:24 +01:00
|
|
|
return $this->registry
|
2012-07-10 22:37:23 +02:00
|
|
|
->getManagerForClass($this->objectClass)
|
2014-07-25 17:59:24 +02:00
|
|
|
->getRepository($this->objectClass)
|
2013-09-23 01:57:58 +02:00
|
|
|
->{$this->options['query_builder_method']}($this->objectClass)
|
2012-07-10 22:28:31 +02:00
|
|
|
->field($this->options['identifier'])->in($identifierValues)
|
2011-05-10 00:06:55 +02:00
|
|
|
->hydrate($hydrate)
|
|
|
|
->getQuery()
|
|
|
|
->execute()
|
|
|
|
->toArray();
|
|
|
|
}
|
|
|
|
}
|