src/EventSubscriber/Composition/SongWriterSubscriber.php line 46

Open in your IDE?
  1. <?php
  2. namespace App\EventSubscriber\Composition;
  3. use App\Entity\Logs\EventLog;
  4. use App\Event\Composition\SongWriter\SongwriterConnectedToProfileEvent;
  5. use App\Event\LogEvent;
  6. use App\Service\AuthenticationService;
  7. use Symfony\Component\EventDispatcher\EventDispatcherInterface;
  8. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  9. class SongWriterSubscriber implements EventSubscriberInterface
  10. {
  11.     /**
  12.      * @var AuthenticationService
  13.      */
  14.     private $authenticationService;
  15.     /**
  16.      * @var EventDispatcherInterface
  17.      */
  18.     private $eventDispatcher;
  19.     public function __construct(
  20.         AuthenticationService $authenticationService,
  21.         EventDispatcherInterface $eventDispatcher
  22.     )
  23.     {
  24.         $this->authenticationService $authenticationService;
  25.         $this->eventDispatcher $eventDispatcher;
  26.     }
  27.     /**
  28.      * @inheritDoc
  29.      */
  30.     public static function getSubscribedEvents(): array
  31.     {
  32.         return [
  33.             SongwriterConnectedToProfileEvent::class => 'onSongwriterConnectedToProfileEvent'
  34.         ];
  35.     }
  36.     /**
  37.      * @param SongwriterConnectedToProfileEvent $event
  38.      */
  39.     public function onSongwriterConnectedToProfileEvent(SongwriterConnectedToProfileEvent $event): void
  40.     {
  41.         $this->eventDispatcher->dispatch(new LogEvent($event->getSongWriter(), $this->authenticationService->getUser(), EventLog::TYPE_SONGWRITER_CONNECTED_TO_PROFILE));
  42.     }
  43. }