/** * @Route("/placements-{year}/{id}-{auth}", requirements={"year" = "\d+", "id" = "\d+"}, name="public_placements") * @Template() */ public function listAction(Year $year, Student $student, $auth) { if (strtolower($student->getAuth()) != strtolower($auth)) { return $this->redirect($this->generateUrl('student_loginreset')); } if (!$year->getPlacementsPublic()) { return $this->redirect($this->generateUrl('main_index')); } $repo = $this->getDoctrine()->getManager()->getRepository('MobilityPlacementBundle:Placement'); $placements = $repo->getPlacements($year->getYear()); return array('year' => $year->getYear(), 'placements' => $placements); }
/** * @Route("/student-{id}-{auth}/remove-wish-{wish}", requirements={"id" = "\d+", "wish" = "\d+"}, name="student_removewish") */ public function removeWishAction(Student $student, $auth, $wish) { if (strtolower($student->getAuth()) != strtolower($auth)) { return $this->redirect($this->generateUrl('student_loginreset')); } else { if ($student->getState() != 0) { return $this->redirect($this->generateUrl('student_login', array('id' => $student->getId(), 'auth' => $auth))); } } $em = $this->getDoctrine()->getManager(); foreach ($student->getWishes() as $w) { $p = $w->getPriority(); if ($p == $wish) { $em->remove($w); } else { if ($p > $wish) { $w->setPriority($p - 1); } } } $em->flush(); return $this->redirect($this->generateUrl('student_wishes', array('id' => $student->getId(), 'auth' => $auth))); }