1 | <?php |
||
24 | abstract class AbstractElasticaToModelTransformer extends BaseTransformer |
||
25 | { |
||
26 | /** |
||
27 | * Manager registry. |
||
28 | * |
||
29 | * @var ManagerRegistry |
||
30 | */ |
||
31 | protected $registry = null; |
||
32 | |||
33 | /** |
||
34 | * Class of the model to map to the elastica documents. |
||
35 | * |
||
36 | * @var string |
||
37 | */ |
||
38 | protected $objectClass = null; |
||
39 | |||
40 | /** |
||
41 | * Optional parameters. |
||
42 | * |
||
43 | * @var array |
||
44 | */ |
||
45 | protected $options = [ |
||
46 | 'hints' => [], |
||
47 | 'hydrate' => true, |
||
48 | 'identifier' => 'id', |
||
49 | 'ignore_missing' => false, |
||
50 | 'query_builder_method' => 'createQueryBuilder', |
||
51 | ]; |
||
52 | |||
53 | /** |
||
54 | * Instantiates a new Mapper. |
||
55 | * |
||
56 | * @param ManagerRegistry $registry |
||
57 | * @param string $objectClass |
||
58 | * @param array $options |
||
59 | */ |
||
60 | 13 | public function __construct(ManagerRegistry $registry, $objectClass, array $options = []) |
|
66 | |||
67 | /** |
||
68 | * Returns the object class that is used for conversion. |
||
69 | * |
||
70 | * @return string |
||
71 | */ |
||
72 | 1 | public function getObjectClass() |
|
76 | |||
77 | /** |
||
78 | * Transforms an array of elastica objects into an array of |
||
79 | * model objects fetched from the doctrine repository. |
||
80 | * |
||
81 | * @param array $elasticaObjects of elastica objects |
||
82 | * |
||
83 | * @throws \RuntimeException |
||
84 | * |
||
85 | * @return array |
||
86 | **/ |
||
87 | 7 | public function transform(array $elasticaObjects) |
|
129 | |||
130 | 2 | public function hybridTransform(array $elasticaObjects) |
|
151 | |||
152 | /** |
||
153 | * {@inheritdoc} |
||
154 | */ |
||
155 | 1 | public function getIdentifierField() |
|
159 | |||
160 | /** |
||
161 | * Fetches objects by theses identifier values. |
||
162 | * |
||
163 | * @param array $identifierValues ids values |
||
164 | * @param bool $hydrate whether or not to hydrate the objects, false returns arrays |
||
165 | * |
||
166 | * @return array of objects or arrays |
||
167 | */ |
||
168 | abstract protected function findByIdentifiers(array $identifierValues, $hydrate); |
||
169 | } |
||
170 |