src/EventSubscriber/UnsetProxyContactSubscriber.php line 11

Open in your IDE?
  1. <?php
  2. namespace App\EventSubscriber;
  3. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  4. use Symfony\Component\Form\FormEvent;
  5. use Symfony\Component\Form\FormEvents;
  6. class UnsetProxyContactSubscriber implements EventSubscriberInterface
  7. {
  8.     public function onSubmitData(FormEvent $event) {
  9.         $contact $event->getData();
  10.         if (!$contact->getIsPreoccupation()) {
  11.             $contact->setProxyContact(null);
  12.         }
  13.     }
  14.     public static function getSubscribedEvents(): array
  15.     {
  16.         return [
  17.             FormEvents::POST_SUBMIT => 'onSubmitData'
  18.         ];
  19.     }
  20. }