<?php
declare(strict_types=1);
namespace App\Service\UserNoTrack\EventListener;
use App\Service\UserNoTrack\Event\UserNoTrackEvent;
use App\Service\UserNoTrack\Notifier\UserNoTrackNotify;
use Psr\Log\LoggerInterface;
use Symfony\Component\EventDispatcher\Attribute\AsEventListener;
#[AsEventListener(event: UserNoTrackEvent::class)]
class UserNoTrackListener
{
public function __construct(
private UserNoTrackNotify $userNoTrackNotify,
private LoggerInterface $logger,
) {
}
public function __invoke(UserNoTrackEvent $event): void
{
try {
$this->userNoTrackNotify->perform($event->getUserNoTrackDto(), $event->getDay());
} catch (\Throwable $e) {
$this->logger->warning($e->getMessage(), ['exception' => $e]);
}
}
}