@@ -159,10 +159,10 @@ private function processInsert(SortableAdapter $ea, array $config, $meta, $objec
159159 {
160160 $ em = $ ea ->getObjectManager ();
161161 $ uow = $ em ->getUnitOfWork ();
162+ $ accessor = $ this ->getPropertyAccessor ();
162163
163- $ old = $ meta ->getReflectionProperty ($ config ['position ' ])->getValue ($ object );
164- $ newPosition = $ meta ->getReflectionProperty ($ config ['position ' ])->getValue ($ object );
165-
164+ $ old = $ accessor ->getValue ($ object , $ config ['position ' ]);
165+ $ newPosition = $ accessor ->getValue ($ object , $ config ['position ' ]);
166166 if (is_null ($ newPosition )) {
167167 $ newPosition = -1 ;
168168 }
@@ -211,7 +211,7 @@ private function processInsert(SortableAdapter $ea, array $config, $meta, $objec
211211
212212 // Set new position
213213 if ($ old < 0 || is_null ($ old )) {
214- $ meta -> getReflectionProperty ( $ config ['position ' ])-> setValue ( $ object , $ newPosition );
214+ $ accessor -> setValue ( $ object , $ config ['position ' ], $ newPosition );
215215 $ ea ->recomputeSingleObjectChangeSet ($ uow , $ meta , $ object );
216216 }
217217 }
@@ -228,6 +228,7 @@ private function processUpdate(SortableAdapter $ea, array $config, $meta, $objec
228228 {
229229 $ em = $ ea ->getObjectManager ();
230230 $ uow = $ em ->getUnitOfWork ();
231+ $ accessor = $ this ->getPropertyAccessor ();
231232
232233 $ changed = false ;
233234 $ groupHasChanged = false ;
@@ -251,7 +252,7 @@ private function processUpdate(SortableAdapter $ea, array $config, $meta, $objec
251252 if (array_key_exists ($ config ['position ' ], $ changeSet )) {
252253 $ oldPosition = $ changeSet [$ config ['position ' ]][0 ];
253254 } else {
254- $ oldPosition = $ meta -> getReflectionProperty ( $ config ['position ' ])-> getValue ( $ object );
255+ $ oldPosition = $ accessor -> getValue ( $ object , $ config ['position ' ]);
255256 }
256257 $ this ->addRelocation ($ oldHash , $ config ['useObjectClass ' ], $ oldGroups , $ oldPosition + 1 , $ this ->maxPositions [$ oldHash ] + 1 , -1 );
257258 $ groupHasChanged = true ;
@@ -353,7 +354,7 @@ private function processUpdate(SortableAdapter $ea, array $config, $meta, $objec
353354 }
354355
355356 // Set new position
356- $ meta -> getReflectionProperty ( $ config ['position ' ])-> setValue ( $ object , $ newPosition );
357+ $ accessor -> setValue ( $ object , $ config ['position ' ], $ newPosition );
357358 $ ea ->recomputeSingleObjectChangeSet ($ uow , $ meta , $ object );
358359 }
359360
@@ -367,7 +368,8 @@ private function processUpdate(SortableAdapter $ea, array $config, $meta, $objec
367368 */
368369 private function processDeletion (SortableAdapter $ ea , array $ config , $ meta , $ object )
369370 {
370- $ position = $ meta ->getReflectionProperty ($ config ['position ' ])->getValue ($ object );
371+ $ accessor = $ this ->getPropertyAccessor ();
372+ $ position = $ accessor ->getValue ($ object , $ config ['position ' ]);
371373
372374 // Get groups
373375 $ groups = $ this ->getGroups ($ meta , $ config , $ object );
@@ -415,6 +417,7 @@ public function postFlush(EventArgs $args)
415417 {
416418 $ ea = $ this ->getEventAdapter ($ args );
417419 $ em = $ ea ->getObjectManager ();
420+ $ accessor = $ this ->getPropertyAccessor ();
418421 foreach ($ this ->relocations as $ hash => $ relocation ) {
419422 $ config = $ this ->getConfiguration ($ em , $ relocation ['name ' ]);
420423 foreach ($ relocation ['deltas ' ] as $ delta ) {
@@ -452,12 +455,12 @@ public function postFlush(EventArgs $args)
452455 }
453456
454457 $ oid = spl_object_hash ($ object );
455- $ pos = $ meta -> getReflectionProperty ( $ config ['position ' ])-> getValue ( $ object );
458+ $ pos = $ accessor -> getValue ( $ object , $ config ['position ' ]);
456459 $ matches = $ pos >= $ delta ['start ' ];
457460 $ matches = $ matches && ($ delta ['stop ' ] <= 0 || $ pos < $ delta ['stop ' ]);
458461 $ value = reset ($ relocation ['groups ' ]);
459462 while ($ matches && ($ group = key ($ relocation ['groups ' ]))) {
460- $ gr = $ meta -> getReflectionProperty ( $ group )-> getValue ($ object );
463+ $ gr = $ accessor -> getValue ($ object, $ group );
461464 if (null === $ value ) {
462465 $ matches = $ gr === null ;
463466 } elseif (is_object ($ gr ) && is_object ($ value ) && $ gr !== $ value ) {
@@ -475,8 +478,9 @@ public function postFlush(EventArgs $args)
475478 $ value = next ($ relocation ['groups ' ]);
476479 }
477480 if ($ matches ) {
478- $ meta ->getReflectionProperty ($ config ['position ' ])->setValue ($ object , $ pos + $ delta ['delta ' ]);
479- $ ea ->setOriginalObjectProperty ($ uow , $ oid , $ config ['position ' ], $ pos + $ delta ['delta ' ]);
481+ $ newValue = $ pos + $ delta ['delta ' ];
482+ $ accessor ->setValue ($ object , $ config ['position ' ], $ newValue );
483+ $ ea ->setOriginalObjectProperty ($ uow , $ oid , $ config ['position ' ], $ newValue );
480484 }
481485 }
482486 }
@@ -580,10 +584,11 @@ private function addRelocation($hash, $class, $groups, $start, $stop, $delta, ar
580584 */
581585 private function getGroups ($ meta , $ config , $ object )
582586 {
587+ $ accessor = $ this ->getPropertyAccessor ();
583588 $ groups = array ();
584589 if (isset ($ config ['groups ' ])) {
585590 foreach ($ config ['groups ' ] as $ group ) {
586- $ groups [$ group ] = $ meta -> getReflectionProperty ( $ group )-> getValue ($ object );
591+ $ groups [$ group ] = $ accessor -> getValue ($ object, $ group );
587592 }
588593 }
589594
0 commit comments