src/EventListener/DigivotionEventListener.php line 35

Open in your IDE?
  1. <?php
  2. namespace App\EventListener;
  3. use App\Event\ApplicantEvent;
  4. use App\Manager\DigivotionManager;
  5. use Doctrine\ORM\EntityManagerInterface;
  6. use Exception;
  7. use Flagception\Manager\FeatureManagerInterface;
  8. class DigivotionEventListener
  9. {
  10.     protected DigivotionManager $digivotionManager;
  11.     private EntityManagerInterface $entityManager;
  12.     private FeatureManagerInterface $featureManager;
  13.     /**
  14.      * DigivotionEventListener constructor.
  15.      */
  16.     public function __construct(
  17.         DigivotionManager $digivotionManager,
  18.         EntityManagerInterface $entityManager,
  19.         FeatureManagerInterface $featureManager
  20.     ) {
  21.         $this->digivotionManager $digivotionManager;
  22.         $this->entityManager $entityManager;
  23.         $this->featureManager $featureManager;
  24.     }
  25.     /**
  26.      * @throws Exception
  27.      */
  28.     public function onApplicantSubmit(ApplicantEvent $applicantEvent)
  29.     {
  30.         if (!$this->featureManager->isActive(FeatureFlagListener::FEATURE_DIGIVOTION)) {
  31.             return;
  32.         }
  33.         $applicant $applicantEvent->getApplicant();
  34.         $this->digivotionManager->postApplicant($applicant);
  35.         $this->entityManager->persist($applicant);
  36.         $this->entityManager->flush();
  37.     }
  38. }