Skip to content

Instantly share code, notes, and snippets.

@dgafka
Created August 15, 2021 12:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dgafka/0c9f5ef918247ed4f3a7d904505aa8e4 to your computer and use it in GitHub Desktop.
Save dgafka/0c9f5ef918247ed4f3a7d904505aa8e4 to your computer and use it in GitHub Desktop.
asynchronous-handling-php-01
<?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