Skip to content

Instantly share code, notes, and snippets.

@mathiasverraes
Created November 27, 2014 17:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mathiasverraes/8d91d87d40170f04868b to your computer and use it in GitHub Desktop.
Save mathiasverraes/8d91d87d40170f04868b 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