<?php declare(strict_types=1);
namespace App\Security\Subscriber;
use App\Service\ReCaptchaFetcher;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\Security\Http\Event\CheckPassportEvent;
class ReCaptchaSubscriber implements EventSubscriberInterface
{
private ReCaptchaFetcher $reCaptchaFetcher;
public function __construct(ReCaptchaFetcher $reCaptchaFetcher)
{
$this->reCaptchaFetcher = $reCaptchaFetcher;
}
public function checkCaptcha(CheckPassportEvent $event): void
{
$this->reCaptchaFetcher->validate();
}
/**
* @return array<string, array<int|string, array<int|string, int|string>|int|string>|string>
*/
public static function getSubscribedEvents(): array
{
return [
CheckPassportEvent::class => 'checkCaptcha',
];
}
}