vendor/can/rest/src/Can/RestBundle/EventListener/RateLimitAuthenticationListener.php line 36

Open in your IDE?
  1. <?php
  2. namespace Can\RestBundle\EventListener;
  3. use Can\RestBundle\Event\GenerateRateLimitKeyEvent;
  4. use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
  5. /**
  6.  * @group ratelimit
  7.  *
  8.  * @package can/rest-bundle
  9.  * @author lechecacharro <lechecacharro@gmail.com>
  10.  */
  11. class RateLimitAuthenticationListener
  12. {
  13.     /**
  14.      * @var TokenStorageInterface
  15.      */
  16.     protected $tokenStorage;
  17.     /**
  18.      * RateLimitAuthenticationListener constructor.
  19.      *
  20.      * @param TokenStorageInterface | null $tokenStorage
  21.      */
  22.     public function __construct(TokenStorageInterface $tokenStorage null)
  23.     {
  24.         $this->tokenStorage $tokenStorage;
  25.     }
  26.     /**
  27.      * @param GenerateRateLimitKeyEvent $event
  28.      */
  29.     public function onGenerateKey(GenerateRateLimitKeyEvent $event): void
  30.     {
  31.         $token null;//$this->tokenStorage->getToken();
  32.         if (null === $token) {
  33.             return;
  34.         }
  35.         $event->addToKey($token);
  36.     }
  37. }