0

I have a PreUpdate listener where I change entry version. I have my own Versioning system (just an integer field with a version number which is increased to the highest+1 when entity is changed).

So if I change sth, version is increased. I also use DoctrineExtensions Sortable. The problem is that I should change version to all of entities where the position is changed.

For instance if I change entity position to 4 I give this entity a new version (let's say 22). And with that five other entities have position being changed (for instance). So also for those five entities I should change the version to 22. Any idea how to achieve this without infinite loop made by PreUpdate event?

Tom
  • 1,203
  • 3
  • 15
  • 35

1 Answers1

0

If you are using \Knp\DoctrineBehaviors you probably should make use of the repository traits of Knp inside your repo class:

use \Knp\DoctrineBehaviors\ORM\Sortable\SortableRepository; 

Then you can make use of reorderEntity/() in your updateAction(), createAaction()

 //reorder..
 $em->getRepository('Bundle:Class')->reorderEntity($entity);
Hauke
  • 257
  • 4
  • 12