Given that I have a Gallery object and Photo object. Gallery has many Photos. I want to be able to manage sequence of the photos in scope of the gallery (the same goes for galleries in scope of galleries).
I need to find and store a int value of a sequence with will be inceremnted value of a sequence that allready exists in DB, either for photos in scope of given gallery or a gallery.
Whats the best way to approach this? First thought was to fetch the sequence in PrePersistCallback and increment it. But a model should not fetch via repository any other models.
I can do the controll in controller, fetching and setting the sequence by hand but this could lead to code duplication.
So maybe there is some special behavior for this build in Doctrine that Im not aware of?
Thanks from the top.
Just to anwser my question for future refrence.
There is nice Sortable behavior extension in “Gedmo” library (along with many others) to do sorting actions on Your entities.
More info:
http://gediminasm.org/article/sortable-behavior-extension-for-doctrine2