<?php
/**
* Created by Elements.at New Media Solutions GmbH
*
*/
namespace App\EventSubscriber;
use App\Model\Shop\Order;
use App\Service\Shop\MailService;
use Elements\Bundle\SkidataTicketingSwebBundle\Event\WeblinkEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class WeblinkEventSubscriber implements EventSubscriberInterface
{
public function __construct(protected MailService $mailService)
{
}
public static function getSubscribedEvents(): array
{
return [
WeblinkEvent::NAME => 'onWeblinkEvent',
];
}
public function onWeblinkEvent(WeblinkEvent $event): void
{
$order = Order::getById($event->getOrderId());
if (!$order->getCompletionEmailSent()) {
$this->mailService->sendCompletionMail($order);
}
}
}