1 | <?php |
||
13 | class ElasticaToModelTransformer extends AbstractElasticaToModelTransformer |
||
14 | { |
||
15 | const ENTITY_ALIAS = 'o'; |
||
16 | |||
17 | /** |
||
18 | * Fetch objects for theses identifier values. |
||
19 | * |
||
20 | * @param array $identifierValues ids values |
||
21 | * @param Boolean $hydrate whether or not to hydrate the objects, false returns arrays |
||
22 | * |
||
23 | * @return array of objects or arrays |
||
24 | */ |
||
25 | 1 | protected function findByIdentifiers(array $identifierValues, $hydrate) |
|
26 | { |
||
27 | 1 | if (empty($identifierValues)) { |
|
28 | return array(); |
||
29 | } |
||
30 | 1 | $hydrationMode = $hydrate ? Query::HYDRATE_OBJECT : Query::HYDRATE_ARRAY; |
|
31 | |||
32 | 1 | $qb = $this->getEntityQueryBuilder(); |
|
33 | 1 | $qb->andWhere($qb->expr()->in(static::ENTITY_ALIAS.'.'.$this->options['identifier'], ':values')) |
|
34 | 1 | ->setParameter('values', $identifierValues); |
|
35 | |||
36 | 1 | $query = $qb->getQuery(); |
|
37 | |||
38 | 1 | foreach ($this->options['hints'] as $hint) { |
|
39 | 1 | $query->setHint($hint['name'], $hint['value']); |
|
40 | 1 | } |
|
41 | |||
42 | 1 | return $query->setHydrationMode($hydrationMode)->execute(); |
|
43 | } |
||
44 | |||
45 | /** |
||
46 | * Retrieves a query builder to be used for querying by identifiers. |
||
47 | * |
||
48 | * @return \Doctrine\ORM\QueryBuilder |
||
49 | */ |
||
50 | 3 | protected function getEntityQueryBuilder() |
|
58 | } |
||
59 |