コード例 #1
0
 /**
  * Shared function to edit/add a page
  */
 private function editPage($page)
 {
     $appId = $this->container->get('keosu_core.curapp')->getCurApp();
     $em = $this->get('doctrine')->getManager();
     $request = $this->get('request');
     //Get Curent theme
     $app = $em->getRepository('KeosuCoreBundle:App')->find($appId);
     //page edit form
     $formBuilder = $this->createFormBuilder($page, array('label' => 'Page edit'));
     $this->buildPageForm($formBuilder);
     $form = $formBuilder->getForm();
     //If we are in POST method, form is submit
     if ($request->getMethod() == 'POST') {
         $form->bind($request);
         if ($form->isValid()) {
             //Storing page
             $em->persist($page);
             $em->flush();
             //Export app to see new page in simulator
             $this->get('keosu_core.exporter')->exportApp();
             return $this->redirect($this->generateUrl('keosu_core_views_page_manage'));
         }
     }
     return $this->render('KeosuCoreBundle:Page:edit.html.twig', array('form' => $form->createView(), 'theme' => $app->getTheme(), 'templateDir' => TemplateUtil::getPageTemplateWebPath()));
 }