/** * @param BClassement $classements */ public function addClassement(Classement $classement) { $classement->setTeam($this); // Si l'objet fait déjà partie de la collection on ne l'ajoute pas if (!$this->classement->contains($classement)) { $this->classement->add($classement); } }
public function getTeamsClass() { $pc = array(); $teams = $this->category->getTeams(); foreach ($teams as $team) { $temp = new Classement(); $temp->setPoints(0); $temp->setRank(0); foreach ($team->getPilots() as $pilot) { $fullname = $pilot->getFullName(); $class = $this->getPilotClass($fullname); if ($class) { $temp->setPoints($class->getPoints() + $temp->getPoints()); $temp->setPilot($pilot); } } $pc[] = $temp; } uasort($pc, function ($a, $b) { if ($a->getPoints() == $b->getPoints()) { return 0; } return $a->getPoints() < $b->getPoints() ? 1 : -1; }); return $pc; }