title: Return response from a kernel event listener
body: <p>I'm using the <em>OAuth2 Server Bundle</em> and I want to authenticate the user for all methods in my controller. It's very similar to the use case done in the documentation <a href="http://symfony.com/doc/current/cookbook/event_dispatcher/before_after_filters.html" rel="nofollow">How to Setup before and after Filters</a>, except that I want to return the response instead of throwing an exception.    </p>
  
  <p><code>onKernelController</code> with <code>FilterControllerEvent</code> gives me access to the controller so I can access <em>OAuth2 Server Bundle's</em> response method. But I can't return any response in there. I can return a response in <code>onKernelController</code> using <code>GetResponseEvent</code>, but it gets called before <code>onKernelController</code>. </p>
  
  <p>I looked into <code>kernel.exception</code> too but <code>getResponse()</code> returns different error messages so I rather not just throw an ambiguous exception.</p>
  
  <p>What's the best practice for what I am trying to accomplish? </p>
  
  <p>This is my code:</p>
  
  <pre><code>public function onKernelController(FilterControllerEvent $event)
  {
      $controller = $event-&gt;getController();
  
      if ($controller[0] instanceof \Foo\Bundle\AuthBundle\Controller\TokenAuthenticatedController) {
  
          $server = $controller[0]-&gt;get('oauth2.server');
          $request = $controller[0]-&gt;get('oauth2.request');
          $response = $controller[0]-&gt;get('oauth2.response');
  
          if (!$server-&gt;verifyResourceRequest($request, $response)) {
              return $server-&gt;getResponse();
          }
      }
  }
  
  public function onKernelRequest(GetResponseEvent $event)
  {
      $event-&gt;setResponse(new Response('Some response', 501));
  }
  </code></pre>