<?php
namespace Witalink\MailTrackerBundle\EventSubscriber\Subscriber;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Witalink\MailTrackerBundle\EventSubscriber\Event\TemplatedEmailEvent;
use Witalink\MailTrackerBundle\EventSubscriber\MailTrackerEvents;
use Witalink\MailTrackerBundle\Services\MailTrackerService;
class MailTrackerSubscriber implements EventSubscriberInterface
{
private MailTrackerService $mailTrackerService;
public function __construct(MailTrackerService $mailTrackerService)
{
$this->mailTrackerService = $mailTrackerService;
}
/**
* @return array
*/
public static function getSubscribedEvents()
{
return [
MailTrackerEvents::MAIL_TRACK_START => [
[
'dispatchStartMailTrack',
// Define the priority if necessary
],
],
];
}
/**
* Dispatch an email once a user is created. This allow him/her to create a password and
* access the account.
*
* @param TemplatedEmailEvent $event
*/
public function dispatchStartMailTrack(TemplatedEmailEvent $event)
{
$this->mailTrackerService->startTrack($event->getTemplatedEmail());
}
}