/** * Dispatch teams into pools of the phase * Do not dispatch teams that are already in a pool * * @param Phase $phase * @return int The number of dispatched teams */ public function dispatchTeamsIntoPools(Phase $phase) { $dispatched = 0; foreach ($phase->getTeams() as $team) { if (!$phase->isTeamPooled($team)) { $pool = $phase->getSmallestPool(); if ($pool) { $pool->addTeam($team); $dispatched++; } } } $this->em->flush(); return $dispatched; }