src/EventSubscriber/SmsGateway/WhenSmsPaidValidateSmsIntentSubscriber.php line 23

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace App\EventSubscriber\SmsGateway;
  3. use App\Event\SmsGateway\SmsIntentValidatedEvent;
  4. use App\Service\SmsGateway\SmsIntentService;
  5. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  6. final class WhenSmsPaidValidateSmsIntentSubscriber implements EventSubscriberInterface
  7. {
  8.     public function __construct(
  9.         private readonly SmsIntentService $smsIntentService
  10.     ) {}
  11.     public static function getSubscribedEvents(): array
  12.     {
  13.         return [
  14.             // This must be triggered earlier than others
  15.             SmsIntentValidatedEvent::class => ['validateSmsIntent', 10],
  16.         ];
  17.     }
  18.     public function validateSmsIntent(SmsIntentValidatedEvent $event): void
  19.     {
  20.         // Mark it as validated.
  21.         $this->smsIntentService->markSmsIntentAsValidated($event->getSmsIntent());
  22.     }
  23. }