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

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