Reputation: 21
I am working in a Symfony2 application (using Doctrine) where that contains the following entities:
C (name, description, isDeleted)
A->B->C
One of the Apps requirement is we must keep in the database all the rows and just set them as deleted in case we need to remove an A, B or C from the database.
Currently every entity has a Manager service that allow to us managing and working with the entities.
However when we need to remove one element of the entities A (isDeleted = true) we must to trigger an action for setting as isDeleted = true all the children relations, in this particular case we need to set as deleted B and C.
Is there any design pattern or good practice (using event dispatcher, doctrine life cycles event or Service way) to achieve this ? In order to keep the code clean and maintainable if we need to add more relationship.
Thanks.
Upvotes: 0
Views: 135
Reputation: 515
I think Soft Delete Extension is good enough for this
https://github.com/Atlantic18/DoctrineExtensions/blob/master/doc/softdeleteable.md
http://doctrine-mongodb-odm.readthedocs.org/en/latest/cookbook/soft-delete-extension.html
Upvotes: 1