Skip to content

Instantly share code, notes, and snippets.

@dgafka
Created August 7, 2021 15:40
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/81c7e4590804823d98a34dbab196e5a3 to your computer and use it in GitHub Desktop.
Save dgafka/81c7e4590804823d98a34dbab196e5a3 to your computer and use it in GitHub Desktop.
handlings-events-php-03
<?php
use Ecotone\Modelling\EventBus;
class PersonRegistrationService
{
public function __construct(private UserRepository $userRepository, private EventBus $event) {}
public function registerUser($registerPersonData)
{
$person = new Person($registerPersonData);
$this->userRepository->save($person);
$this->event->publish(new PersonWasRegistered($person->getPersonId()));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment