Created
August 15, 2021 12:02
-
-
Save dgafka/0c9f5ef918247ed4f3a7d904505aa8e4 to your computer and use it in GitHub Desktop.
asynchronous-handling-php-01
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 PersonRegistrationEventSubscriber | |
{ | |
#[Asynchronous("asynchronous_messages")] | |
#[EventHandler] | |
public function sendWelcomeEmail(PersonWasRegistered $event, EmailSender $emailSender): void | |
{ | |
$person = $this->userRepository->getById($event->getPersonId()); | |
$emailSender->sendWelcomeTo($person); | |
} | |
#[Asynchronous("asynchronous_messages")] | |
#[EventHandler] | |
public function synchronizeExternalService(PersonWasRegistered $event, ExternalIntegratedService $externalService): void | |
{ | |
$person = $this->userRepository->getById($event->getPersonId()); | |
$externalService->synchronizeUser($person); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment