original_string: public function createAction(Request $request, $categoryId)
      {
          $em = $this->getDoctrine()->getManager();
  
          /** @var Category $category */
          $category = $em->getRepository('EcommerceBundle:Category')->find($categoryId);
  
          if (!$category) {
              throw $this->createNotFoundException('Unable to find Category entity.');
          }
  
          $entity  = new Category();
          $form = $this->createForm(new SubcategoryType(), $entity);
          $entity->setParentCategory($category);
  
          $form->bind($request);
  
          if ($form->isValid()) {
              $em = $this->getDoctrine()->getManager();
              $em->persist($entity);
              $em->flush();
  
              $this->get('session')->getFlashBag()->add('success', 'category.created');
  
              return $this->redirect($this->generateUrl('ecommerce_category_show', array('id' => $entity->getId())));
          }
  
          return array(
              'entity' => $entity,
              'category' => $category,
              'form'   => $form->createView(),
          );
      }
code: public function createAction(Request $request, $categoryId)
      {
          $em = $this->getDoctrine()->getManager();
  
          /** @var Category $category */
          $category = $em->getRepository('EcommerceBundle:Category')->find($categoryId);
  
          if (!$category) {
              throw $this->createNotFoundException('Unable to find Category entity.');
          }
  
          $entity  = new Category();
          $form = $this->createForm(new SubcategoryType(), $entity);
          $entity->setParentCategory($category);
  
          $form->bind($request);
  
          if ($form->isValid()) {
              $em = $this->getDoctrine()->getManager();
              $em->persist($entity);
              $em->flush();
  
              $this->get('session')->getFlashBag()->add('success', 'category.created');
  
              return $this->redirect($this->generateUrl('ecommerce_category_show', array('id' => $entity->getId())));
          }
  
          return array(
              'entity' => $entity,
              'category' => $category,
              'form'   => $form->createView(),
          );
      }
code_tokens: public function createAction ( Request $ request , $ categoryId ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; /** @var Category $category */ $ category = $ em -> getRepository ( 'EcommerceBundle:Category' ) -> find ( $ categoryId ) ; if ( ! $ category ) { throw $ this -> createNotFoundException ( 'Unable to find Category entity.' ) ; } $ entity = new Category ( ) ; $ form = $ this -> createForm ( new SubcategoryType ( ) , $ entity ) ; $ entity -> setParentCategory ( $ category ) ; $ form -> bind ( $ request ) ; if ( $ form -> isValid ( ) ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ em -> persist ( $ entity ) ; $ em -> flush ( ) ; $ this -> get ( 'session' ) -> getFlashBag ( ) -> add ( 'success' , 'category.created' ) ; return $ this -> redirect ( $ this -> generateUrl ( 'ecommerce_category_show' , array ( 'id' => $ entity -> getId ( ) ) ) ) ; } return array ( 'entity' => $ entity , 'category' => $ category , 'form' => $ form -> createView ( ) , ) ; }
docstring: Creates a new Category entity.
  
  @param Request $request    The request
  @param int     $categoryId The category id
  
  @throws NotFoundHttpException
  @return array|RedirectResponse
  
  @Route("/")
  @Method("POST")
  @Template("EcommerceBundle:Category:new.html.twig")
docstring_tokens: Creates a new Category entity .