← Back
Editing: NewReportListener.php
<?php namespace App\EventListener; use App\Entity\Report; use App\Service\ReportService; use Doctrine\Bundle\DoctrineBundle\EventSubscriber\EventSubscriberInterface; use Doctrine\Persistence\Event\LifecycleEventArgs; use Symfony\Component\Mailer\Exception\TransportExceptionInterface; class NewReportListener implements EventSubscriberInterface { public function __construct(private readonly ReportService $reportService) { } /** * @throws TransportExceptionInterface */ public function postPersist(LifecycleEventArgs $args): void { $entity = $args->getObject(); if (!$entity instanceof Report) { return; } if ($entity->isAlertManager()) { $this->reportService->sendNewReportConfirmation($entity); } } public function getSubscribedEvents() { return ['postPersist']; } }
Save File
Cancel