title: beforeFilter function not redirecting in Symfony2
body: <p>I have implemented following code to run a code on before any action of any controller. However, the <code>beforeFilter()</code> function not redirecting to the route I have specified. Instead it takes the user to the location where the user clicked.</p>
  
  <pre><code>//My Listener
  namespace Edu\AccountBundle\EventListener;
  use Symfony\Component\DependencyInjection\Container;
  use Symfony\Component\HttpKernel\Event\FilterControllerEvent;
  
  class BeforeControllerListener
  {
      public function onKernelController(FilterControllerEvent $event)
      {
          $controller = $event-&gt;getController();
          if (!is_array($controller))
          {
              //not a controller do nothing
              return;
          }
          $controllerObject = $controller[0];
          if (is_object($controllerObject) &amp;&amp; method_exists($controllerObject, "beforeFilter"))
          //Set a predefined function to execute Before any controller Executes its any method
          {
              $controllerObject-&gt;beforeFilter();
          }
      }
  }
  //I have registered it already
  
  //My Controller
  class LedgerController extends Controller
  {        
      public function beforeFilter()
      {   
          $commonFunction = new CommonFunctions();
          $dm = $this-&gt;getDocumentManager();
          if ($commonFunction-&gt;checkFinancialYear($dm) == 0 ) {
              $this-&gt;get('session')-&gt;getFlashBag()-&gt;add('error', 'Sorry');
              return $this-&gt;redirect($this-&gt;generateUrl('financialyear'));//Here it is not redirecting
          }
      }
  }
  
  public function indexAction() {}
  </code></pre>
  
  <p>Please help, What is missing in it.
  Thanks Advance</p>