<?php declare(strict_types=1);
namespace App\EventSubscriber\SmsGateway;
use App\Event\SmsGateway\SmsIntentValidatedEvent;
use App\Service\SmsGateway\SmsIntentService;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
final class WhenSmsPaidValidateSmsIntentSubscriber implements EventSubscriberInterface
{
public function __construct(
private readonly SmsIntentService $smsIntentService
) {}
public static function getSubscribedEvents(): array
{
return [
// This must be triggered earlier than others
SmsIntentValidatedEvent::class => ['validateSmsIntent', 10],
];
}
public function validateSmsIntent(SmsIntentValidatedEvent $event): void
{
// Mark it as validated.
$this->smsIntentService->markSmsIntentAsValidated($event->getSmsIntent());
}
}