title: How to get at runtime the route name in Symfony2 when using the yaml routes description?
body: <p>Here you can find my <em>n</em>-th question on Symfony2.</p>
  
  <p>I'm working with a <a href="https://github.com/makerlabs/PagerBundle/wiki">pagination bundle</a> that uses the route name provided in the <code>routing.yml</code> file.
  From my perspective, this approach is not flexible and lead to a dirty code, since if I change the name of the route, then I have to look at all the Twig templates or PHP files to update the route name. This is ok for small Web applications, but will provide such a bug for larger applications and also need an high burden for the developer.</p>
  
  <p>So, I was wondering to pass a string variable <strong>x</strong> to the <code>Pager</code> object provided by the above mentioned bundle. The string <strong>x</strong> should be initialized within the controller and has to provide the desired route name as given in the <code>routing.yml</code> file.</p>
  
  <p>Let me give an example. The routing file is the following:</p>
  
  <pre><code>//routing.yml
   AcmeTestBundle_listall:
  pattern:  /test/page/{page}
  defaults: { _controller: AcmeTestBundle:List:listall, page: 1 }
  requirements:
      page:  \d+   
  </code></pre>
  
  <p>Then the related controller is:</p>
  
  <pre><code>//use something....
  class ListController extends Controller
  {
  
    public function exampleAction($page)
    {
      $array = range(1, 100);
      $adapter = new ArrayAdapter($array);
      $pager = new Pager($adapter, array('page' =&gt; $page, 'limit' =&gt; 25));
  
      return array('pager' =&gt; $pager);  
    }
  }
  </code></pre>
  
  <p>Then, in the twig template, the <code>$pager</code> receives the route name that refer to the above bundle</p>
  
  <pre><code>{% if pager.isPaginable %}
     {{ paginate(pager, 'AcmeTestBundle_listall') }}
  {% endif %}
  {% for item in pager.getResults %}
     &lt;p&gt;{{ item }}&lt;/p&gt;
  {% endfor %}
  </code></pre>
  
  <p>Any idea of how to get the 'AcmeTestBundle_listall' string value at runtime just inside the controller?</p>