src/EventSubscriber/InspectionFormSubscriber.php line 44
<?phpnamespace App\EventSubscriber;use App\Event\AppEvents;use App\Event\FormEvent;use DateTime;use Doctrine\ORM\EntityManagerInterface;use Symfony\Component\EventDispatcher\EventSubscriberInterface;/*** Class InspectionFormListener*/class InspectionFormSubscriber implements EventSubscriberInterface{/*** @var EntityManagerInterface*/private $entityManager;/*** InspectionFormListener constructor.** @param EntityManagerInterface $entityManager*/public function __construct(EntityManagerInterface $entityManager){$this->entityManager = $entityManager;}/*** {@inheritdoc}*/public static function getSubscribedEvents(): array{return [AppEvents::INSPECTION_FORM_CREATED => 'onInspectionFormCreated',];}/*** @param FormEvent $event*/public function onInspectionFormCreated(FormEvent $event): void{$property = $event->getForm()->getProperty();$property->setInspectionDate(new DateTime());$this->entityManager->flush();}}