Beispiel #1
0
 /**
  * @param AuthenticationEvent $event
  */
 public function onAuthenticationSuccess(AuthenticationEvent $event)
 {
     /** @var User $user */
     $user = $this->userManager->findOneById($event->getAuthenticationToken()->getUser()->getId());
     // logging
     $userLog = new UserLog();
     $userLog->setUser($user)->setIpSource($this->request->getCurrentRequest()->getClientIp())->save();
 }
 /**
  * @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()];
 }