vendor/noxlogic/ratelimit-bundle/Noxlogic/RateLimitBundle/EventListener/OauthKeyGenerateListener.php line 27

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