コード例 #1
0
 /**
  *
  *
  * @param integer $applicationId
  * @param Request $request
  *
  * @return RedirectResponse|Response
  */
 public function editAction($applicationId, Request $request)
 {
     $entity = $this->appRepository->find($applicationId);
     if (false == $entity) {
         $entity = new App();
         $entity->setContainer($this->container);
     }
     $this->pushNavigationElement($entity);
     $form = $this->createForm(new ApplicationType(), $entity);
     if ('POST' == $request->getMethod()) {
         $form->submit($request);
         if ($form->isValid()) {
             $this->getEm()->persist($entity);
             $this->getEm()->flush();
             $this->get('unifik_system.router_invalidator')->invalidate();
             $this->addFlashSuccess($this->get('translator')->trans('%entity% has been saved.', array('%entity%' => $entity)));
             if ($request->request->has('save')) {
                 return $this->redirect($this->generateUrl('unifik_system_backend_application'));
             }
             return $this->redirect($this->generateUrl($entity->getRoute(), $entity->getRouteParams()));
         } else {
             $this->addFlashError('Some fields are invalid.');
         }
     }
     return $this->render('UnifikSystemBundle:Backend/Application/Application:edit.html.twig', array('entity' => $entity, 'form' => $form->createView()));
 }