22
33namespace FOS \ElasticaBundle \Doctrine ;
44
5+ use Doctrine \Common \Persistence \ManagerRegistry ;
56use FOS \ElasticaBundle \HybridResult ;
6- use FOS \ElasticaBundle \Transformer \ElasticaToModelTransformerInterface ;
7+ use FOS \ElasticaBundle \Transformer \AbstractElasticaToModelTransformer as BaseTransformer ;
78use FOS \ElasticaBundle \Transformer \HighlightableModelInterface ;
8- use Symfony \Component \PropertyAccess \PropertyAccessorInterface ;
99
1010/**
1111 * Maps Elastica documents with Doctrine objects
1212 * This mapper assumes an exact match between
1313 * elastica documents ids and doctrine object ids.
1414 */
15- abstract class AbstractElasticaToModelTransformer implements ElasticaToModelTransformerInterface
15+ abstract class AbstractElasticaToModelTransformer extends BaseTransformer
1616{
1717 /**
1818 * Manager registry.
19+ *
20+ * @var ManagerRegistry
1921 */
2022 protected $ registry = null ;
2123
@@ -38,21 +40,14 @@ abstract class AbstractElasticaToModelTransformer implements ElasticaToModelTran
3840 'query_builder_method ' => 'createQueryBuilder ' ,
3941 );
4042
41- /**
42- * PropertyAccessor instance.
43- *
44- * @var PropertyAccessorInterface
45- */
46- protected $ propertyAccessor ;
47-
4843 /**
4944 * Instantiates a new Mapper.
5045 *
51- * @param object $registry
46+ * @param ManagerRegistry $registry
5247 * @param string $objectClass
5348 * @param array $options
5449 */
55- public function __construct ($ registry , $ objectClass , array $ options = array ())
50+ public function __construct (ManagerRegistry $ registry , $ objectClass , array $ options = array ())
5651 {
5752 $ this ->registry = $ registry ;
5853 $ this ->objectClass = $ objectClass ;
@@ -69,16 +64,6 @@ public function getObjectClass()
6964 return $ this ->objectClass ;
7065 }
7166
72- /**
73- * Set the PropertyAccessor.
74- *
75- * @param PropertyAccessorInterface $propertyAccessor
76- */
77- public function setPropertyAccessor (PropertyAccessorInterface $ propertyAccessor )
78- {
79- $ this ->propertyAccessor = $ propertyAccessor ;
80- }
81-
8267 /**
8368 * Transforms an array of elastica objects into an array of
8469 * model objects fetched from the doctrine repository.
@@ -111,10 +96,7 @@ public function transform(array $elasticaObjects)
11196 // sort objects in the order of ids
11297 $ idPos = array_flip ($ ids );
11398 $ identifier = $ this ->options ['identifier ' ];
114- $ propertyAccessor = $ this ->propertyAccessor ;
115- usort ($ objects , function ($ a , $ b ) use ($ idPos , $ identifier , $ propertyAccessor ) {
116- return $ idPos [$ propertyAccessor ->getValue ($ a , $ identifier )] > $ idPos [$ propertyAccessor ->getValue ($ b , $ identifier )];
117- });
99+ usort ($ objects , $ this ->getSortingClosure ($ idPos , $ identifier ));
118100
119101 return $ objects ;
120102 }
@@ -138,7 +120,7 @@ public function hybridTransform(array $elasticaObjects)
138120 }
139121
140122 /**
141- * {@inheritdoc }
123+ * {@inheritDoc }
142124 */
143125 public function getIdentifierField ()
144126 {
0 commit comments