title: Symfony2: Change rendered view with a listener
body: <p>I would like to render different views in different context in my Symfony2 project.
  I'm using multiple routes for the same actions and I would like to render a different page (view) but with the same controller.
  For example I have:</p>
  
  <pre><code>@Route("/articles/show", name="articles_show")
  @Route("/mobile/articles/show", name="mobile_articles_show")
  </code></pre>
  
  <p><strong>Both routes</strong> are using <strong>the same action</strong> : ArticlesController:showAction(), but should render 2 differents templates (for mobile users and regulars ones).</p>
  
  <pre><code>show.html.twig
  mobile.show.html.twig
  </code></pre>
  
  <p>I do not want to use a if statement or whatever in my controller, so I created a listener (similar to a preExecute function)</p>
  
  <p>Here is a part or my <strong>config.yml</strong> that defines my <strong>listener</strong></p>
  
  <pre><code>services:
      controller.pre_execute_listener:
          class: MyProject\MyBundle\Listener\ControllerListener
          arguments: ["@security.context", "@doctrine", "@router", "@session"]
          tags:- { name: kernel.event_listener, event: kernel.controller, method: preExecute }
  </code></pre>
  
  <p>I was thinking about doing something like that in the listener <strong>preExecute function</strong>:</p>
  
  <pre><code>if(substr($route,0,7) == 'mobile_'){
      $view = 'mobile.'.$view;
  }
  </code></pre>
  
  <p>Unfortunately I cannot find a way to get <strong>$view</strong> or update the view "on the fly", just before it's rendered.</p>
  
  <p>I hope my question is clear enough, thanks in advance, any idea is welcome :)</p>
  
  <p>J.</p>