Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Doctrine2 + soft delete as a state pattern

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?

like image 847
canni Avatar asked Feb 20 '12 11:02

canni


1 Answers

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.

like image 166
mbh Avatar answered Nov 07 '22 11:11

mbh