Esempio n. 1
0
 /**
  * Check if all participants are cancelled or finished and if so, finish the race
  * @param RaceSection $section
  */
 public function checkIfFinished(RaceSection $section)
 {
     $done = 0;
     /** @var Registration $reg */
     foreach ($section->getValidRegistrations() as $reg) {
         if ($reg->isDone()) {
             $done += 1;
         }
     }
     if ($done == $section->getValidRegistrations()->count()) {
         $section->setStatus(RaceSectionStatus::FINISHED);
         $em = $this->getDoctrine()->getManager();
         $em->persist($section);
         $em->flush();
     }
 }