/** * Mark the given team as being not any longer part of the given race. * * @Route("/race/{race}/deregister/{team}", name="registration_delete") * @Method("POST") * @Security("has_role('ROLE_REGISTRATION')") */ public function deleteAction(Team $team, Race $race) { // sanity check $races = array(); /** @var \AppBundle\Entity\Registration $registration */ foreach ($team->getRegistrations() as $registration) { array_push($races, $registration->getSection()->getRace()); } if (!in_array($race, $races)) { $this->addFlash('error', 'Falsche Inputdaten!'); } else { /** @var \AppBundle\Entity\Registration $myRegistrationForThisRace */ $myRegistrationForThisRace = null; // find the "lane" foreach ($team->getRegistrations() as $registration) { if ($registration->getSection()->getRace() == $race) { $myRegistrationForThisRace = $registration; } } if (is_null($myRegistrationForThisRace)) { $this->addFlash('error', 'Falsche Inputdaten! Konnte Startbahn nicht ermitteln...'); } else { // mark the "lane" of the section as cancelled $myRegistrationForThisRace->setDeregistered(); $this->getDoctrine()->getManager()->flush(); $this->addFlash('notice', 'Mannschaft abgemeldet!'); } } return $this->redirectToRoute('race_show', array('event' => $race->getEvent()->getId(), 'race' => $race->getId())); }