<?php
namespace App\EventSubscriber;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
class UnsetProxyContactSubscriber implements EventSubscriberInterface
{
public function onSubmitData(FormEvent $event) {
$contact = $event->getData();
if (!$contact->getIsPreoccupation()) {
$contact->setProxyContact(null);
}
}
public static function getSubscribedEvents(): array
{
return [
FormEvents::POST_SUBMIT => 'onSubmitData'
];
}
}