After my post about “Good ORMs do not call __construct a.k.a. where to fire my Domain Events”, nice discussions (and trolling) are happening in the Barcelona Engineering Slack Channel. Thanks to everyone for the feedback, ideas and concerns. You are more than welcome! The main concerns are:
- How do I fetch an Entity from ElasticSearch, using new and without firing the Event?
- How do I create stubs on the Entity that is firing the Domain Event?
- What are pros and cons of firing the Domain Event in the __constructor or in the named constructor?
So, I’ll take the original code as a starting point, and I’ll suggest different strategies to answer those questions.