I just found a contribution from Benjamin Eberlei, regarding business logic changes in the domain layer on a more abstract level: Doctrine and Domain Events
Brief quote and summary from the blog post:
The Domain Event Pattern allows to attach events to entities and
dispatch them to event listeners only when the transaction of the
entity was successfully executed. This has several benefits over
traditional event dispatching approaches:
- Puts focus on the behavior in the domain and what changes the domain triggers.
- Promotes decoupling in a very simple way
- No reference to the event dispatcher and all the listeners required except in the Doctrine UnitOfWork.
- No need to use unexplicit Doctrine Lifecycle events that are triggered on all update operations.
Each method requiring action should:
- Call a "raise" method with the event name and properties.
- The "raise" method should create a new DomainEvent object and set it into an events array stored in the entity in memory.
- An event listener should listen to Doctrine lifecycle events (e.g. postInsert), keeping entities in memory that (a) implement events, and (b) have events to process.
- This event listener should dispatch a new (custom) event in the preFlush/postFlush callback containing the entity of interest and any relevant information.
- A second event listener should listen for these custom events and trigger the logic necessary (e.g. onNewEntityAddedToTree)
I have not implemented this yet, but it sounds like it should accomplish exactly what I'm looking for in a more automated fashion that the method I actually implemented.