vendor/noxlogic/ratelimit-bundle/EventListener/OauthKeyGenerateListener.php line 26

Open in your IDE?
  1. <?php
  2. namespace Noxlogic\RateLimitBundle\EventListener;
  3. use Noxlogic\RateLimitBundle\Events\GenerateKeyEvent;
  4. use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
  5. class OauthKeyGenerateListener
  6. {
  7.     /**
  8.      * @var TokenStorageInterface
  9.      */
  10.     protected $tokenStorage;
  11.     /**
  12.      * @param $tokenStorage
  13.      */
  14.     public function __construct($tokenStorage)
  15.     {
  16.         $this->tokenStorage $tokenStorage;
  17.     }
  18.     /**
  19.      * @param GenerateKeyEvent $event
  20.      */
  21.     public function onGenerateKey(GenerateKeyEvent $event)
  22.     {
  23.         $token $this->tokenStorage->getToken();
  24.         if (! $token instanceof \FOS\OAuthServerBundle\Security\Authentication\Token\OAuthToken) {
  25.             return;
  26.         }
  27.         $event->addToKey($token->getToken());
  28.     }
  29. }