-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
EventRecorderCapabilities should have recordEvents() method #4
Comments
Hello! Thanks for creating this issue. As it is documented here, Thus, adding Seems like it should be separated. What if you create your own In this case you can use it inside your commands and do not duplicate code: class EventRecorder extends BornFree\TacticianDomainEvent\Recorder\EventRecorder
{
public function recordEvents(ContainsRecordedEvents $recordedEventsContainer)
{
foreach($recordedEventsContainer->releaseEvents() as $event) {
$this->recordedEvents[] = $event;
}
}
} |
Thanks for the insightful response - after reflecting on your point, I agree with you that would result in "strangeness", just to cover this one case. As a follow up, can I confirm that I am using the library correctly? I'm using Zend Expressive, and what I'm trying to do is capture the domain events raised by my Entities as they are executed within my Command Handler. At the moment, I'm passing the EventRecorder to my command handler via the command handler factory. This is used to record the events raised by the various entities as they are called by the command handler. I'm using the above loop for each entity once I've completed any state changes. However this results is several loops for several entities as I collect up all the raised events. The controller/action has already attached listeners and the results are processed as normal via the commandbus. My point is that it seems a bit, I don't know if clunky is the right word, but it would be nice if my commands could implement an interface/trait pair to simplify this process somehow? not sure if I'm doing this right! Does that make sense? Am I missing something obvious? |
It would be very convenient if EventRecorderCapabilities had the following method:
This way I wouldn't need to keep implementing it in my command handlers - I could simply call $this->eventRecorder->recordEvents($entity);
I'm happy to put this together in a pull request if you prefer.
The text was updated successfully, but these errors were encountered: