public function removePoolFromPhase(Pool $pool) { $isClear = true; /** @var Game $game */ foreach ($pool->getGames() as $game) { if ($game->isPlayed()) { $isClear = false; } else { $pool->removeGame($game); $this->em->remove($game); } } if ($isClear) { $pool->getPhase()->removePool($pool); $this->em->remove($pool); } $this->em->flush(); return $isClear; }