/** * @param RoundEvent $roundCompletedEvent * @param string $name * @param EventDispatcherInterface $dispatcher */ public function onRoundCompleted(RoundEvent $roundCompletedEvent, $name, EventDispatcherInterface $dispatcher) { $tournamentComplete = true; foreach ($this->roundGears as $roundNumber => $gears) { if ($gears->isRoundCompleted()) { $this->log(sprintf('onRoundCompleted, round %d complete', $roundNumber)); continue; } if ($gears->getRound()->getId() == $roundCompletedEvent->getRound()->getId()) { $this->log(sprintf('onRoundCompleted, round %d CONSIDER complete', $roundNumber)); continue; } $this->log(sprintf('onRoundCompleted, round %d NOT complete', $roundNumber)); $tournamentComplete = false; break; } if ($tournamentComplete) { $tournamentCompletedEvent = new TournamentEvent(); $tournamentCompletedEvent->setTournament($this->getTournament()); $dispatcher->dispatch(EngineEvents::TOURNAMENT_COMPLETED, $tournamentCompletedEvent); } }
/** * check if the provided group completes the associated round and proceed accordingly * * @param Group $group * @param EventDispatcherInterface $dispatcher */ protected function handleGroupCompletesRound(Group $group, EventDispatcherInterface $dispatcher) { $round = $group->getRound(); if ($round->isClosed()) { $this->log('handleGroupCompletesRound, ROUND COMPLETE!'); $roundCompletedEvent = new RoundEvent(); $roundCompletedEvent->setRound($round); $dispatcher->dispatch(EngineEvents::ROUND_COMPLETED, $roundCompletedEvent); } }