/**
  *
  *
  * @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()));
 }
예제 #2
0
 /**
  * Load
  *
  * @param ObjectManager $manager
  */
 public function load(ObjectManager $manager)
 {
     $metadata = $manager->getClassMetaData('Unifik\\SystemBundle\\Entity\\App');
     $metadata->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_NONE);
     $appBackend = new App();
     $appBackend->setId(1);
     $appBackend->setName('Backend');
     $appBackend->setPrefix('admin');
     $appBackend->setOrdering(1);
     $manager->persist($appBackend);
     $appFrontend = new App();
     $appFrontend->setId(2);
     $appFrontend->setName('Frontend');
     $appFrontend->setOrdering(2);
     $manager->persist($appFrontend);
     $manager->flush();
     $this->addReference('app-backend', $appBackend);
     $this->addReference('app-frontend', $appFrontend);
 }