Exemplo n.º 1
0
 /**
  * Creates a new Section entity.
  *
  * @Route("/", name="section_create")
  * @Method("POST")
  * @Template("EnglishPagesBundle:Section:new.html.twig")
  */
 public function createAction(Request $request)
 {
     $section = new Section();
     $form = $this->createCreateForm($section);
     $form->handleRequest($request);
     $page = new Page();
     $page->setSortOrder(1);
     $page->setMenuName('Home');
     $page->setSection($section);
     if ($form->isValid()) {
         $em = $this->getDoctrine()->getManager();
         $em->persist($section);
         $em->persist($page);
         $em->flush();
         return $this->redirect($this->generateUrl('section'));
     }
     return array('section' => $section, 'form' => $form->createView());
 }