public function testAddKey()
 {
     $request = new Request();
     $event = new GenerateKeyEvent($request, "foo");
     $this->assertEquals("foo", $event->getKey());
     $event->addToKey("bar");
     $this->assertEquals("foo:bar", $event->getKey());
     $event->addToKey("baz");
     $this->assertEquals("foo:bar:baz", $event->getKey());
     $event->addToKey("");
     $this->assertEquals("foo:bar:baz:", $event->getKey());
 }
 /**
  * @param GenerateKeyEvent $event
  */
 public function onGenerateKey(GenerateKeyEvent $event)
 {
     $token = $this->securityContext->getToken();
     if (!$token instanceof \FOS\OAuthServerBundle\Security\Authentication\Token\OAuthToken) {
         return;
     }
     $event->addToKey($token->getToken());
 }
 /**
  * Apply rate limits separately to different IPs.
  *
  * @param GenerateKeyEvent $event
  */
 public function setRateLimitKey(GenerateKeyEvent $event)
 {
     $event->addToKey($event->getRequest()->getClientIp());
 }