src/App/Security/Subscriber/ReCaptchaSubscriber.php line 19

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace App\Security\Subscriber;
  3. use App\Service\ReCaptchaFetcher;
  4. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  5. use Symfony\Component\Security\Http\Event\CheckPassportEvent;
  6. class ReCaptchaSubscriber implements EventSubscriberInterface
  7. {
  8.     private ReCaptchaFetcher $reCaptchaFetcher;
  9.     public function __construct(ReCaptchaFetcher $reCaptchaFetcher)
  10.     {
  11.         $this->reCaptchaFetcher $reCaptchaFetcher;
  12.     }
  13.     public function checkCaptcha(CheckPassportEvent $event): void
  14.     {
  15.         $this->reCaptchaFetcher->validate();
  16.     }
  17.     /**
  18.      * @return array<string, array<int|string, array<int|string, int|string>|int|string>|string>
  19.      */
  20.     public static function getSubscribedEvents(): array
  21.     {
  22.         return [
  23.             CheckPassportEvent::class => 'checkCaptcha',
  24.         ];
  25.     }
  26. }