Drop support for app()->call()
when calling event handlers
#180
-
app()->call([$this, $handlerClassOrMethod], $parameters); The reasoning being that you could inject extra dependencies in event handlers. I think we don't need that functionality for two reasons:
Note the obscurity of this error. It happened because a projector had an implementation like so: class CartProjector extends Projector
{
public function onCartInitialized(CartInitialized $cartInitialized): void { /* … */ }
} The error doesn't mention this projector though. Instead the container fails because it tries to autowire
So I propose to replace There's one caveat: right now both the aggregate root UUID and the stored event are also (optionally) passed to the handler, and the implementation should actually be: $this->$handlerClassOrMethod($storedEvent->event, $storedEvent, $storedEvent->aggregate_uuid) I don't think this is necessary though: the AR UUID is already exposed on the event itself via its meta data, and we could easily keep a reference to its stored event ID as well in its meta data: $event->storedEvent();
$event->aggregateRootUuid(); // This one is already possible |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
Agreed!
Indeed. Let's just implement your proposal! 👍 |
Beta Was this translation helpful? Give feedback.
-
Merged in v5: 99e083d |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
Agreed!
Indeed.
Let's just implement your proposal! 👍