/** * Ajoute une Traj au cache de Trajs de this * @param Traj $traj * @return void */ public function addTrajCache(Traj $traj) { if (is_null($this->cacheTrajs)) { $this->cacheTrajs = new TrajCollection(); } $this->cacheTrajs->ajout($traj); }
/** * Renvoie les Trajs liés à l'objet * @return TrajCollection */ public function getTrajs() { if (is_null($this->cacheTrajs)) { $this->cacheTrajs = TrajBusiness::getByQg($this); $this->cacheTrajs->store(); } return $this->cacheTrajs; }
/** * Renvoie les Qgs liés à une collection de Trajs * @param TrajCollection $trajs * @return QgCollection */ public static function getFromTrajs(TrajCollection $trajs) { $ids = $trajs->getIdQgs(); if (!$ids) { return new QgCollection(); } $req = "SELECT * FROM qg WHERE idQg IN (" . $ids . ");"; return DbHandler::collFromQuery($req, 'Qg', 'QgCollection'); }
/** * Renvoie les Hexas liés à une collection de Trajs * @param TrajCollection $trajs * @return HexaCollection */ public static function getFromTrajs(TrajCollection $trajs) { $ids = $trajs->getIdHexas(); if (!$ids) { return new HexaCollection(); } $req = "SELECT * FROM hexa WHERE idHexa IN (" . $ids . ");"; return DbHandler::collFromQuery($req, 'Hexa', 'HexaCollection'); }
/** * Renvoie la collection mais sans les Trajs dont le joueur fourni en paramètre n'a pas le droit de voir les trajectoire et les ordres * @param Joueur $joueur * @return QgCollection */ public function filterByDroitVoirTraj(Joueur $joueur) { $ret = new TrajCollection(); foreach ($this as $traj) { /** @var Traj $traj */ if ($traj->getQg()->droitVoirTraj($joueur)) { $ret->ajout($traj); } } return $ret; }