Esempio n. 1
0
 /**
  * @Template("PGSCoreDomainBundle:UserProfile:new.html.twig")
  */
 public function editAction(Request $request)
 {
     $id = $request->get('id');
     if (!($user = $this->userManager->findOneById($id))) {
         throw $this->createNotFoundException('Invalid `user` given');
     }
     if (!($userProfile = $this->userProfileManager->findOneById($id))) {
         $userProfile = new UserProfile();
         $userProfile->setId($id);
     }
     $form = $this->createForm($this->get('pgs.core.form.type.user_profile'), $userProfile);
     if ($request->getMethod() == "POST") {
         $form->submit($request);
         if ($form->isValid()) {
             $this->processForm($form);
             return new RedirectResponse($this->generateUrl('homepage'));
         }
     }
     return ['model' => 'User Profile', 'userProfile' => $userProfile, 'form' => $form->createView()];
 }