Doctrine2 docs said that soft-delete behavior should be better implemented as a State pattern But not provide any example of that implementation.
How to achieve soft delete behavior using a state pattern?
I think they refer to filters which are available since version 2.2:
The filter functionality works on SQL level. Whether an SQL query is generated in a Persister, during lazy loading, in extra lazy collections or from DQL. Each time the system iterates over all the enabled filters, adding a new SQL part as a filter returns.
The DoctrineExtensions library includes a "soft-delete" behaviour. You might want to have a look at their implementation to see how it works in detail.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With