title: Symfony2 how to redirect to an action without hardcoding route name?
body: <p>I've an <strong>abstract</strong> <code>CRUDController</code> extending <code>Controller</code>. In my <code>newAction</code>, os success, i'd like to redirect to <code>showAction($slug)</code> using <code>redirect</code> method:</p>
  
  <pre><code>return $this-&gt;redirect($this-&gt;generateUrl($route, $params));
  </code></pre>
  
  <p>But <code>newAction</code> is <strong>actually called in the subclass</strong> <code>UserController</code>, so i can't specify route name <code>$route</code> in my <code>CRUDController</code>.</p>
  
  <pre><code>class UserController extends CRUDController { }
  
  abstract class CRUDController extends Controller
  {
      /** @Template */
      public function showAction($slug) { }
  
      /** @Template */
      public function newAction(Request $request)
      {
  
          $model = $this-&gt;createModel();
          $form  = $this-&gt;createForm($this-&gt;createType(), $model);
  
          if('GET' == $request-&gt;getMethod())
              return array('form' =&gt; $form-&gt;createView());
  
          $form-&gt;bindRequest($request);
  
          if(!$form-&gt;isValid()) return array(
              'errors' =&gt; $this-&gt;get('validator')-&gt;validate($model),
              'form'   =&gt; $form-&gt;createView()
          );
  
          $em = $this-&gt;getDoctrine()-&gt;getEntityManager();
          $em-&gt;persist($model);
          $em-&gt;flush();
  
          // Success, redirect to showAction($slug)
      }
  
  }
  </code></pre>
  
  <p>An example of routes:</p>
  
  <pre><code>users_show:
    pattern: /users/show/{slug}
    defaults: { _controller: AcmeSecurityBundle:User:show }
    requirements:
      _method:  GET
  
  users_new:
    pattern: /users/new
    defaults: { _controller: AcmeSecurityBundle:User:new }
    requirements:
      _method:  GET
  
  users_create:
    pattern: /users/new
    defaults: { _controller: AcmeSecurityBundle:User:new }
    requirements:
      _method:  POST
  </code></pre>