@@ -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 ();
163162
164- $ old = $ accessor ->getValue ($ object , $ config ['position ' ]);
165- $ newPosition = $ accessor ->getValue ($ object , $ config ['position ' ]);
163+ $ old = $ meta ->getReflectionProperty ($ config ['position ' ])->getValue ($ object );
164+ $ newPosition = $ meta ->getReflectionProperty ($ config ['position ' ])->getValue ($ object );
165+
166166 if (is_null ($ newPosition )) {
167167 $ newPosition = -1 ;
168168 }
@@ -211,8 +211,7 @@ private function processInsert(SortableAdapter $ea, array $config, $meta, $objec
211211
212212 // Set new position
213213 if ($ old < 0 || is_null ($ old )) {
214- $ accessor ->setValue ($ object , $ config ['position ' ], $ newPosition );
215- $ ea ->recomputeSingleObjectChangeSet ($ uow , $ meta , $ object );
214+ $ this ->setFieldValue ($ ea , $ object , $ config ['position ' ], $ old , $ newPosition );
216215 }
217216 }
218217
@@ -228,7 +227,6 @@ private function processUpdate(SortableAdapter $ea, array $config, $meta, $objec
228227 {
229228 $ em = $ ea ->getObjectManager ();
230229 $ uow = $ em ->getUnitOfWork ();
231- $ accessor = $ this ->getPropertyAccessor ();
232230
233231 $ changed = false ;
234232 $ groupHasChanged = false ;
@@ -252,7 +250,7 @@ private function processUpdate(SortableAdapter $ea, array $config, $meta, $objec
252250 if (array_key_exists ($ config ['position ' ], $ changeSet )) {
253251 $ oldPosition = $ changeSet [$ config ['position ' ]][0 ];
254252 } else {
255- $ oldPosition = $ accessor -> getValue ( $ object , $ config ['position ' ]);
253+ $ oldPosition = $ meta -> getReflectionProperty ( $ config ['position ' ])-> getValue ( $ object );
256254 }
257255 $ this ->addRelocation ($ oldHash , $ config ['useObjectClass ' ], $ oldGroups , $ oldPosition + 1 , $ this ->maxPositions [$ oldHash ] + 1 , -1 );
258256 $ groupHasChanged = true ;
@@ -354,8 +352,7 @@ private function processUpdate(SortableAdapter $ea, array $config, $meta, $objec
354352 }
355353
356354 // Set new position
357- $ accessor ->setValue ($ object , $ config ['position ' ], $ newPosition );
358- $ ea ->recomputeSingleObjectChangeSet ($ uow , $ meta , $ object );
355+ $ this ->setFieldValue ($ ea , $ object , $ config ['position ' ], $ oldPosition , $ newPosition );
359356 }
360357
361358 /**
@@ -368,8 +365,7 @@ private function processUpdate(SortableAdapter $ea, array $config, $meta, $objec
368365 */
369366 private function processDeletion (SortableAdapter $ ea , array $ config , $ meta , $ object )
370367 {
371- $ accessor = $ this ->getPropertyAccessor ();
372- $ position = $ accessor ->getValue ($ object , $ config ['position ' ]);
368+ $ position = $ meta ->getReflectionProperty ($ config ['position ' ])->getValue ($ object );
373369
374370 // Get groups
375371 $ groups = $ this ->getGroups ($ meta , $ config , $ object );
@@ -417,7 +413,6 @@ public function postFlush(EventArgs $args)
417413 {
418414 $ ea = $ this ->getEventAdapter ($ args );
419415 $ em = $ ea ->getObjectManager ();
420- $ accessor = $ this ->getPropertyAccessor ();
421416 foreach ($ this ->relocations as $ hash => $ relocation ) {
422417 $ config = $ this ->getConfiguration ($ em , $ relocation ['name ' ]);
423418 foreach ($ relocation ['deltas ' ] as $ delta ) {
@@ -455,12 +450,12 @@ public function postFlush(EventArgs $args)
455450 }
456451
457452 $ oid = spl_object_hash ($ object );
458- $ pos = $ accessor -> getValue ( $ object , $ config ['position ' ]);
453+ $ pos = $ meta -> getReflectionProperty ( $ config ['position ' ])-> getValue ( $ object );
459454 $ matches = $ pos >= $ delta ['start ' ];
460455 $ matches = $ matches && ($ delta ['stop ' ] <= 0 || $ pos < $ delta ['stop ' ]);
461456 $ value = reset ($ relocation ['groups ' ]);
462457 while ($ matches && ($ group = key ($ relocation ['groups ' ]))) {
463- $ gr = $ accessor -> getValue ($ object, $ group );
458+ $ gr = $ meta -> getReflectionProperty ( $ group )-> getValue ($ object );
464459 if (null === $ value ) {
465460 $ matches = $ gr === null ;
466461 } elseif (is_object ($ gr ) && is_object ($ value ) && $ gr !== $ value ) {
@@ -478,9 +473,7 @@ public function postFlush(EventArgs $args)
478473 $ value = next ($ relocation ['groups ' ]);
479474 }
480475 if ($ matches ) {
481- $ newValue = $ pos + $ delta ['delta ' ];
482- $ accessor ->setValue ($ object , $ config ['position ' ], $ newValue );
483- $ ea ->setOriginalObjectProperty ($ uow , $ oid , $ config ['position ' ], $ newValue );
476+ $ this ->setFieldValue ($ ea , $ object , $ config ['position ' ], $ pos , $ pos + $ delta ['delta ' ]);
484477 }
485478 }
486479 }
@@ -584,11 +577,10 @@ private function addRelocation($hash, $class, $groups, $start, $stop, $delta, ar
584577 */
585578 private function getGroups ($ meta , $ config , $ object )
586579 {
587- $ accessor = $ this ->getPropertyAccessor ();
588580 $ groups = array ();
589581 if (isset ($ config ['groups ' ])) {
590582 foreach ($ config ['groups ' ] as $ group ) {
591- $ groups [$ group ] = $ accessor -> getValue ($ object, $ group );
583+ $ groups [$ group ] = $ meta -> getReflectionProperty ( $ group )-> getValue ($ object );
592584 }
593585 }
594586
0 commit comments