/**
  * {@inheritDoc}
  */
 public function getUser()
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'getUser', array());
     return parent::getUser();
 }
 public function RefereesAction(Request $request)
 {
     if ($this->check('RidwanEntityBundle:Referees') != null) {
         return $this->redirect($this->generateUrl('ridwan_site_home'));
     }
     $em = $this->getDoctrine()->getManager();
     $database = $em->getRepository('RidwanEntityBundle:Referees')->findBy(array('user' => $this->getUser()->getId()));
     $referee1 = new Referees();
     $referee2 = new Referees();
     $entity = new RefereeAndUser();
     $entity->getReferees()->add($referee1);
     $entity->getReferees()->add($referee2);
     $form = $this->createForm(new RefereeAndUserType(), $entity, array('action' => $this->generateUrl('ridwan_user_volunteer_referees'), 'method' => 'POST', 'attr' => array('class' => 'form-horizontal center')));
     $form->handleRequest($request);
     if ($form->isValid()) {
         $entity = $form->getData();
         $entity->setUser($this->getUser());
         $referee1 = $entity->getReferees()[0];
         $referee2 = $entity->getReferees()[1];
         $referee1->setUser($this->getUser()->getId());
         $referee2->setUser($this->getUser()->getId());
         $volunteer = $em->getRepository('RidwanEntityBundle:Volunteerpersonal')->findOneBy(array('user' => $this->getUser()->getId()));
         $volunteer->setStatus(1);
         $em->persist($volunteer);
         $profile = new Profile();
         $profile->setUser($this->getUser());
         $availability = new Availability();
         $availability->setUser($this->getUser());
         // $em->persist($availability);
         $em->persist($referee1);
         $em->persist($referee2);
         // $em->persist($profile);
         $em->flush();
         return $this->render('RidwanUserBundle:Welcome:completed.html.twig');
     }
     return $this->render('RidwanUserBundle:Welcome:referees.html.twig', array('database' => $database, 'form' => $form->createView()));
 }