src/EventListener/ReviewMailListener.php line 20

Open in your IDE?
  1. <?php
  2. namespace App\EventListener;
  3. use App\Event\EntityEvent;
  4. use App\Mailer\Mailer;
  5. use Twig\Environment;
  6. class ReviewMailListener
  7. {
  8.     private $from;
  9.     private $to;
  10.     public function __construct(private readonly Mailer $mailer, private readonly Environment $templatingstring $emailFrom, array $emailTo)
  11.     {
  12.         $this->from $emailFrom;
  13.         $this->to $emailTo;
  14.     }
  15.     public function onNewReview(EntityEvent $event): void
  16.     {
  17.         $review $event->getEntity();
  18.         $this->mailer->send(
  19.             $this->templating->render('/Mail/review_new.html.twig', ['review' => $review]),
  20.             'Nouvel avis client sur VPauto.fr',
  21.             $this->to,
  22.             $this->from
  23.         );
  24.     }
  25. }