src/Form/Subscriber/VehicleSubscriber.php line 41

Open in your IDE?
  1. <?php
  2. namespace App\Form\Subscriber;
  3. use Doctrine\ORM\EntityManagerInterface;
  4. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  5. use Symfony\Component\Form\FormEvent;
  6. use Symfony\Component\Form\FormEvents;
  7. class VehicleSubscriber implements EventSubscriberInterface
  8. {
  9.     /**
  10.      * @var EntityManagerInterface
  11.      */
  12.     private $em;
  13.     /**
  14.      * Constructor.
  15.      *
  16.      * @param \Doctrine\ORM\EntityManagerInterface $manager
  17.      */
  18.     public function __construct(EntityManagerInterface $manager)
  19.     {
  20.         $this->em $manager;
  21.     }
  22.     public static function getSubscribedEvents()
  23.     {
  24.         return [FormEvents::POST_SUBMIT => 'onPostSubmit'];
  25.     }
  26.     /**
  27.      * Populate hourly cost according to selected vehicle
  28.      *
  29.      * @param \Symfony\Component\Form\FormEvent $event
  30.      *
  31.      * @throws \Doctrine\ORM\NonUniqueResultException
  32.      */
  33.     public function onPostSubmit(FormEvent $event)
  34.     {
  35.         $data $event->getData();
  36. //        dump($data);
  37.     }
  38. }