Ejemplo n.º 1
0
 /**
  * @Route("/installer/step/1")
  * @Template()
  */
 public function administratorAction()
 {
     $em = $this->getDoctrine()->getEntityManager();
     if ($this->get('session')->get('installer_user_id')) {
         $user = $em->find('ClubUserBundle:User', $this->get('session')->get('installer_user_id'));
     } else {
         $user = new \Club\UserBundle\Entity\User();
         $user->setMemberNumber($em->getRepository('ClubUserBundle:User')->findNextMemberNumber());
         $profile = new \Club\UserBundle\Entity\Profile();
         $user->setProfile($profile);
         $profile->setUser($user);
         $email = new \Club\UserBundle\Entity\ProfileEmail();
         $email->setContactType('home');
         $email->setProfile($profile);
         $profile->setProfileEmail($email);
     }
     $form = $this->createForm(new \Club\InstallerBundle\Form\AdministratorStep(), $user);
     if ($this->getRequest()->getMethod() == 'POST') {
         $form->bindRequest($this->getRequest());
         if ($form->isValid()) {
             $group = $em->getRepository('ClubUserBundle:Group')->findOneBy(array('group_name' => 'Super Administrators'));
             $group->addUsers($user);
             $em->persist($user);
             $em->flush();
             $this->get('session')->set('installer_user_id', $user->getId());
             return $this->redirect($this->generateUrl('club_installer_installer_location'));
         }
     }
     return array('form' => $form->createView());
 }
Ejemplo n.º 2
0
 protected function getUser($user)
 {
     $em = $this->getDoctrine()->getEntityManager();
     if (!$user->getProfile()->getProfileAddress()) {
         $address = new \Club\UserBundle\Entity\ProfileAddress();
         $address->setContactType('home');
         $address->setProfile($user->getProfile());
         $user->getProfile()->setProfileAddress($address);
     }
     if (!$user->getProfile()->getProfilePhone()) {
         $phone = new \Club\UserBundle\Entity\ProfilePhone();
         $phone->setContactType('home');
         $phone->setProfile($user->getProfile());
         $user->getProfile()->setProfilePhone($phone);
     }
     if (!$user->getProfile()->getProfileEmail()) {
         $email = new \Club\UserBundle\Entity\ProfileEmail();
         $email->setContactType('home');
         $email->setProfile($user->getProfile());
         $user->getProfile()->setProfileEmail($email);
     }
     return $user;
 }
Ejemplo n.º 3
0
 /**
  * Remove profile_emails
  *
  * @param Club\UserBundle\Entity\ProfileEmail $profileEmails
  */
 public function removeProfileEmail(\Club\UserBundle\Entity\ProfileEmail $profileEmails)
 {
     $this->profile_emails->removeElement($profileEmails);
 }
 protected function buildUser($user)
 {
     $em = $this->getDoctrine()->getManager();
     if (!count($user->getProfile()->getProfileAddress())) {
         $address = new \Club\UserBundle\Entity\ProfileAddress();
         $address->setProfile($user->getProfile());
         $user->getProfile()->setProfileAddress($address);
     }
     if (!count($user->getProfile()->getProfilePhone())) {
         $phone = new \Club\UserBundle\Entity\ProfilePhone();
         $phone->setProfile($user->getProfile());
         $user->getProfile()->setProfilePhone($phone);
     }
     if (!count($user->getProfile()->getProfileEmail())) {
         $email = new \Club\UserBundle\Entity\ProfileEmail();
         $email->setProfile($user->getProfile());
         $user->getProfile()->setProfileEmail($email);
         $user->getProfile()->addProfileEmail($email);
     }
     return $user;
 }