<?php
namespace App\Listener;
use App\Event\SupervisorAssignedEvent;
use App\Manager\NotificationManager;
use Psr\Log\LoggerInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class SupervisorAssignedSubscriber implements EventSubscriberInterface
{
public const SUPERVISOR_ASSIGNED_DONE = 'supervisor.assigned.done';
/**
* @var NotificationManager
*/
protected $notificationManager;
/**
* @var LoggerInterface
*/
protected $logger;
public function __construct(
NotificationManager $notificationManager,
LoggerInterface $logger
) {
$this->notificationManager = $notificationManager;
$this->logger = $logger;
}
/**
* @return array
*/
public static function getSubscribedEvents(): array
{
return [
static::SUPERVISOR_ASSIGNED_DONE => 'onSupervisorAssignedDone',
];
}
/**
* Bootstraps status change hooks.
*
* @param SupervisorAssignedEvent $event
*
* @return void
*/
public function onSupervisorAssignedDone(SupervisorAssignedEvent $event): void
{
$request = $event->getSubject();
$notification = $this->notificationManager->getSupervisorAssignedNotification($request);
$this->notificationManager->notify($notification);
}
}