Doctrine2 + soft delete as a state pattern
-
28-10-2019 - |
سؤال
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.
لا تنتمي إلى StackOverflow