src/Domain/Module/Subscriber/UserCreatedEventSubscriber.php line 26

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