title: switch case entities in symfony2
body: <p>how can i use switch case to persist an entity from many entities
  i use a variable to rely with the entity
  this code may be help you to understand my question ??</p>
  
  <pre><code>public function addAction($name, Request $request) {
      switch ($name) {
          case 'Article':
              $name = new Article();
              $nameType = new ArticleType();
              break;
         case 'Comment':
              $name = new Comment();
              $nameType = new CommentType();
              break;
         case 'Blog':
              $name = new Blog();
              $nameType = new BlogType();
              break;
  
           return $name;
           return $nameType;
      }
  
      $form = $this-&gt;get('form.factory')-&gt;create($nameType, $name);
      $em = $this-&gt;getDoctrine()-&gt;getManager();
      $em-&gt;persist($name);
      $em-&gt;flush();
  
      return $this-&gt;render('WFBundle:Blog:add.html.twig', array(
          'form' =&gt; $form-&gt;createView(),
      ));
  }
  </code></pre>