<?php
namespace App\EventListener;
use App\Event\EntityEvent;
use App\Mailer\Mailer;
use Twig\Environment;
class ReviewMailListener
{
private $from;
private $to;
public function __construct(private readonly Mailer $mailer, private readonly Environment $templating, string $emailFrom, array $emailTo)
{
$this->from = $emailFrom;
$this->to = $emailTo;
}
public function onNewReview(EntityEvent $event): void
{
$review = $event->getEntity();
$this->mailer->send(
$this->templating->render('/Mail/review_new.html.twig', ['review' => $review]),
'Nouvel avis client sur VPauto.fr',
$this->to,
$this->from
);
}
}