Skip to content
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

Add Symfony inspired typed event dispatcher method #17106

Merged
merged 1 commit into from
Sep 12, 2019

Conversation

ChristophWurst
Copy link
Member

Instead of

$this->dispatcher->dispatch(OC\User\Events\PostLoginEvent::class, $postLoginEvent);

you can

$this->dispatcher->dispatchTyped($postLoginEvent);

Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
@@ -75,6 +76,10 @@ public function dispatch(string $eventName,
$this->dispatcher->dispatch($eventName, $event);
}

public function dispatchTyped(Event $event): void {
$this->dispatch(get_class($event), $event);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know I could have passed the event to Symfony and let it do the get_class magic but I would rather have that on our side so we are absolutely sure our expected logic is performed (should they ever change it)

@blizzz blizzz merged commit ac48a9b into master Sep 12, 2019
@blizzz blizzz deleted the feature/dispatch-typed-event branch September 12, 2019 07:25
@MorrisJobke
Copy link
Member

That's where all of #14552 started 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3. to review Waiting for reviews enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants