src/EventListener/IncompletRelance2Subscriber.php line 42

Open in your IDE?
  1. <?php
  2. namespace App\EventListener;
  3.  
  4. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  5. use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
  6. use Doctrine\ORM\EntityManagerInterface;
  7. use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
  8. use App\Utils\MailerService;
  9. use App\Entity\Notification;
  10. use App\Event\NotifyEvent;
  11. use App\Event\IncompletRelance2Event;
  12. class IncompletRelance2Subscriber implements EventSubscriberInterface
  13. {
  14.   private $mailer;
  15.   private $parameters;
  16.   private $em;
  17.   
  18.   private $dispatcher;
  19.   
  20.   public function __construct(EntityManagerInterface  $emParameterBagInterface $parametersMailerService $mailerEventDispatcherInterface $dispatcher) {
  21.       $this->mailer $mailer;
  22.       $this->parameters $parameters;
  23.       $this->em $em;
  24.       $this->dispatcher $dispatcher;
  25.   }
  26.   public static function getSubscribedEvents(): array
  27.   {
  28.       return [
  29.         IncompletRelance2Event::NAME => 'notify'
  30.       ];
  31.   }
  32.  
  33.   public function notify(IncompletRelance2Event $event) {
  34.     $dossier $event->getDossier();
  35.     
  36.     $vars = [
  37.       'offre' => $dossier->getOffre(),
  38.       'raison_sociale' => $dossier->getEntreprise(), 
  39.       'date' =>  $dossier->getCreatedAt(), 
  40.     ];
  41.     
  42.     $object = [
  43.       'dossier' => $dossier,
  44.       'event' => $event::NAME,
  45.       'vars' => $vars,
  46.     ];
  47.     // Envoi notification membre
  48.     $this->dispatcher->dispatch(new NotifyEvent($object), NotifyEvent::NAME);
  49.                 
  50.   }
  51. }