src/Domain/Auth/Subscriber/UserCreatedEventSubscriber.php line 25

Open in your IDE?
  1. <?php
  2. namespace App\Domain\Auth\Subscriber;
  3. use App\Domain\Auth\Event\UserCreatedEvent;
  4. use App\Domain\Auth\Service\UserRegisterService;
  5. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  6. class UserCreatedEventSubscriber implements EventSubscriberInterface
  7. {
  8.     private UserRegisterService $service;
  9.     public function __construct(UserRegisterService $service)
  10.     {
  11.         $this->service $service;
  12.     }
  13.     public static function getSubscribedEvents(): array
  14.     {
  15.         return [
  16.             UserCreatedEvent::class => 'onCreated',
  17.         ];
  18.     }
  19.     public function onCreated(UserCreatedEvent $event): void
  20.     {
  21.         $this->service->updateUser($event->getUser());
  22.     }
  23. }