예제 #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());
 }
예제 #2
0
 /**
  * Displays a form to create a new Page entity.
  *
  * @Route("/{sectionid}/{pageid}/new", name="pages_new")
  * @Method("GET")
  * @Template()
  */
 public function newAction($sectionid, $pageid)
 {
     if (false === $this->get('security.context')->isGranted('ROLE_PAGEADMIN')) {
         throw new AccessDeniedException();
     }
     $em = $this->getDoctrine()->getManager();
     $section = $em->getRepository('EnglishPagesBundle:Section')->find($sectionid);
     $parent = $em->getRepository('EnglishPagesBundle:Page')->find($pageid);
     $sort = 1;
     $page = new Page();
     $page->setSection($section);
     $page->setParent($parent);
     $page->setSortorder($sort);
     $form = $this->createCreateForm($page);
     $label = $em->getRepository('EnglishFilesBundle:Label')->findNewsletterLabel();
     $labelid = $label->getId();
     return array('page' => $page, 'form' => $form->createView(), 'labelid' => $labelid);
 }