1 | <?php |
||
15 | abstract class AbstractElasticaToModelTransformer extends BaseTransformer |
||
16 | { |
||
17 | /** |
||
18 | * Manager registry. |
||
19 | * |
||
20 | * @var ManagerRegistry |
||
21 | */ |
||
22 | protected $registry = null; |
||
23 | |||
24 | /** |
||
25 | * Class of the model to map to the elastica documents. |
||
26 | * |
||
27 | * @var string |
||
28 | */ |
||
29 | protected $objectClass = null; |
||
30 | |||
31 | /** |
||
32 | * Optional parameters. |
||
33 | * |
||
34 | * @var array |
||
35 | */ |
||
36 | protected $options = array( |
||
37 | 'hydrate' => true, |
||
38 | 'identifier' => 'id', |
||
39 | 'ignore_missing' => false, |
||
40 | 'query_builder_method' => 'createQueryBuilder', |
||
41 | ); |
||
42 | |||
43 | /** |
||
44 | * Instantiates a new Mapper. |
||
45 | * |
||
46 | * @param ManagerRegistry $registry |
||
47 | * @param string $objectClass |
||
48 | * @param array $options |
||
49 | */ |
||
50 | 3 | public function __construct(ManagerRegistry $registry, $objectClass, array $options = array()) |
|
56 | |||
57 | /** |
||
58 | * Returns the object class that is used for conversion. |
||
59 | * |
||
60 | * @return string |
||
61 | */ |
||
62 | public function getObjectClass() |
||
66 | |||
67 | /** |
||
68 | * Transforms an array of elastica objects into an array of |
||
69 | * model objects fetched from the doctrine repository. |
||
70 | * |
||
71 | * @param array $elasticaObjects of elastica objects |
||
72 | * |
||
73 | * @throws \RuntimeException |
||
74 | * |
||
75 | * @return array |
||
76 | **/ |
||
77 | 1 | public function transform(array $elasticaObjects) |
|
103 | |||
104 | 1 | public function hybridTransform(array $elasticaObjects) |
|
121 | |||
122 | /** |
||
123 | * {@inheritDoc} |
||
124 | */ |
||
125 | public function getIdentifierField() |
||
129 | |||
130 | /** |
||
131 | * Fetches objects by theses identifier values. |
||
132 | * |
||
133 | * @param array $identifierValues ids values |
||
134 | * @param Boolean $hydrate whether or not to hydrate the objects, false returns arrays |
||
135 | * |
||
136 | * @return array of objects or arrays |
||
137 | */ |
||
138 | abstract protected function findByIdentifiers(array $identifierValues, $hydrate); |
||
139 | } |
||
140 |