src/EventSubscriber/CollectionsSubscriber.php line 27
<?phpnamespace App\EventSubscriber;use App\Entity\Collections;use App\Event\Collections\CollectionsCreatedEvent;use App\Event\Collections\CollectionsDeletedEvent;use App\Event\Collections\CollectionsUpdatedEvent;use App\Service\NotificationService;use Symfony\Component\EventDispatcher\EventSubscriberInterface;class CollectionsSubscriber implements EventSubscriberInterface{public function __construct(private NotificationService $notificationService){}public static function getSubscribedEvents(): array{return [CollectionsCreatedEvent::class => 'onCreated',CollectionsUpdatedEvent::class => 'onUpdated',CollectionsDeletedEvent::class => 'onDeleted',];}public function onCreated(CollectionsCreatedEvent $event): void{$collections = $event->getCollections();if ($collections instanceof Collections) {$this->notificationService->notifyUser($collections->getEstablishment()->getUser(),'Collection créée',sprintf("Vous venez de créer la collection <strong>%s</strong>",$collections->getName()),$collections);}}public function onUpdated(CollectionsUpdatedEvent $event): void{$collections = $event->getCollections();if ($collections instanceof Collections) {$this->notificationService->notifyUser($collections->getEstablishment()->getUser(),'Collection modifiée',sprintf("Vous venez de modifier la collection <strong>%s</strong>",$collections->getName()),$collections);}}public function onDeleted(CollectionsDeletedEvent $event): void{$collections = $event->getCollections();if ($collections instanceof Collections) {$this->notificationService->notifyUser($collections->getEstablishment()->getUser(),'Collection supprimée',sprintf("Vous venez de supprimer la collection <strong>%s</strong>",$collections->getName()),$collections);}}}