Esempio n. 1
0
 public function postPersist(LifecycleEventArgs $args)
 {
     //$userManager = $this->get('fos_user.user_manager');
     $entity = $args->getEntity();
     $em = $args->getEntityManager();
     //$user = $em->findUserByUsername($entity);
     if ($entity instanceof \ne0shad0w\ZephyrAdminCoreBundle\ZephyrAdminCoreBundle\Entity\FosUser) {
         //	print_r($entity) ;
         $info = new MemberInfo();
         $item = $em->getRepository('\\ne0shad0w\\ZephyrAdminCoreBundle\\ZephyrAdminCoreBundle\\Entity\\FosUser')->find($entity->getId());
         $info->setIdUser($item);
         $em->persist($info);
         $em->flush();
     }
 }
 public function personnelAction(Request $request)
 {
     $userManager = $this->container->get('fos_user.user_manager');
     $user = $this->get('security.token_storage')->getToken()->getUser();
     //$MemberInfo = new MemberInfo();
     $MemberInfo = $this->getDoctrine()->getRepository('MembreBundle:MemberInfo')->find($user->getId());
     if (!$MemberInfo) {
         $MemberInfo = new MemberInfo();
         $MemberInfo->setIdUser($user);
     }
     $form = $this->createForm(new MembreType(), $MemberInfo);
     $form->handleRequest($request);
     if ($request->getMethod() == 'POST') {
         if ($form->isValid()) {
             $em = $this->getDoctrine()->getManager();
             $em->persist($MemberInfo);
             $em->flush();
             $this->get('session')->getFlashBag()->add('info', 'Information mise à jour');
         }
     }
     return $this->render('MembreBundle:Security:personnel.html.twig', array('form' => $form->createView()));
     //return $this->render('MembreBundle:Security:personnel.html.twig');
 }