/**
  * Creates a new Application entity.
  *
  */
 public function newAction(Request $request)
 {
     $userId = $request->attributes->get('user');
     $teamId = $request->attributes->get('team');
     $origin = $request->attributes->get('origin');
     $application = new Application();
     $user = $this->getDoctrine()->getRepository('AppBundle:User')->find($userId);
     $team = $this->getDoctrine()->getRepository('AppBundle:Team')->find($teamId);
     $application->setUser($user);
     $application->setTeam($team);
     $application->setOrigin($origin);
     $form = $this->createForm(new ApplicationType(), $application);
     $form->handleRequest($request);
     if ($form->isSubmitted() && $form->isValid()) {
         $em = $this->getDoctrine()->getManager();
         $em->persist($application);
         $em->flush();
         return $this->redirectToRoute('game_show', array('id' => $team->getGame()->getId()));
     }
     return $this->render('AppBundle:application:new.html.twig', array('application' => $application, 'form' => $form->createView()));
 }
Example #2
0
 /**
  * @param  Application $application
  */
 public function addApplication(\AppBundle\Entity\Application $application)
 {
     $application->setTeam($this);
     $this->application[] = $application;
 }