Skip to content

Instantly share code, notes, and snippets.

@muhamed-didovic
Forked from mathiasverraes/events.php
Last active August 29, 2015 14:11
Show Gist options
  • Save muhamed-didovic/bd8cdb27104ddec304e2 to your computer and use it in GitHub Desktop.
Save muhamed-didovic/bd8cdb27104ddec304e2 to your computer and use it in GitHub Desktop.
<?php
$dispatcher = new EventDispatcher;
class SendWelcomeEmail implements QueuedEventHandler {
public function when(Event $event) {
// delegate to whenUserHasRegistered, whenFoo..
}
private function whenUserHasRegistered(UserHasRegistered $event) {
// do stuff with $event->getUserId();
}
}
$dispatcher->listen(UserHasRegistered::class, $sendWelcomeEmail);
$dispatcher->fire(new UserHasRegistered($userid, ...));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment