Last active
November 25, 2017 18:04
-
-
Save Great-Antique/91dd24b16c9fe92b3bfb232719f93383 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Controller { | |
public function handle(Request $request) { | |
$event = new TryToRegisterUserEvent($request->get('email')); | |
$this->dispatcher->dispatch($event); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class TryToRegisterUserEventHandler { | |
public function handle(TryToRegisterUserEvent $event) { | |
$user = $this->userRegistrationDomainService->register($event->getEmail()); | |
$userRegistered = new UserRegisteredEvent($user); | |
$this->dispatcher->dispatch($userRegistered); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class UserRegisteredEventHandler { | |
public function handle(UserRegisteredEvent $event) { | |
$user = $event->getUser(); | |
// do something... | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment