سؤال

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.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top