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