/** * Fetch a resource * * @param mixed $id * @return LogApiProblem|mixed */ public function fetch($id) { try { $sNom = $this->getEvent()->getRouteParam('roster_name'); $key = $this->getRequestKey('APIRtK-roster', array($sNom)); if ($this->cache->hasItem($key) === true) { return $this->cache->getItem($key); } /* @var $oTabRoster \Commun\Model\Roster */ $oTabRoster = $this->getTableRoster()->selectBy(array("nom" => $sNom)); if (!$oTabRoster) { return new LogApiProblem(404, sprintf($this->_getServTranslator()->translate("Le roster [ %s ] demandé n'a pas été trouvé."), $sNom), $this->_getServTranslator()->translate("Not Found"), $this->_getServTranslator()->translate("Roster inconnu"), array('nomRoster' => $sNom), $this->_service); } $aRoles = $this->getTableRole()->fetchAll()->toArray(); $oResult = new RosterEntity(); $oResult->setNom($sNom); $aRoleModifie = array(); foreach ($aRoles as $aRole) { $aLstPerso = $this->getTableRosterHasPersonnage()->getListePersonnage($aRole['idRole'], $oTabRoster->getIdRoster()); $aRole["personnages"] = $aLstPerso; $aRoleModifie[] = $aRole; } $oResult->setRoles($aRoleModifie); $this->addItem($key, $oResult); return $oResult; } catch (\Exception $ex) { return \Core\Util\ParseException::tranformeExceptionToApiProblem($ex, $this->_service); } }
/** * Fetch a resource * Paramètre supplémentaire : * ?withids=<code>0</code> pas d'id superflus,<code>1</code> ajout des differents ID. * ?spe=<code>-1</code> toutes les spés,<code>0</code> spé 1, <code>1</code> spé 2, <code>2</code> spé 3,<code>3</code> spé 4 . * @param mixed $id nom du personnage dont on veut le loot * @return ApiProblem|mixed */ public function fetch($sRoster) { try { $sRoster = $this->getEvent()->getRouteParam('nom_roster'); $iSpe = $this->getEvent()->getQueryParam('spe', -1); $key = $this->getRequestKey('APIRtK-loot', array($sRoster, $iSpe)); if ($this->cache->hasItem($key) === true) { return $this->cache->getItem($key); } $oResult = $this->getTableRoster()->getStatRoster($sRoster, $iSpe); $this->addItem($key, $oResult); return $oResult; } catch (\Exception $ex) { return \Core\Util\ParseException::tranformeExceptionToApiProblem($ex, $this->_service); } }
/** * Fetch a resource * Paramètre supplémentaire : * ?withids=<code>0</code> pas d'id superflus,<code>1</code> ajout des differents ID. * ?spe=<code>-1</code> toutes les spés,<code>0</code> spé 1, <code>1</code> spé 2, <code>2</code> spé 3,<code>3</code> spé 4 . * @param mixed $id nom du personnage dont on veut le loot * @return ApiProblem|mixed */ public function fetch($id) { try { $sRoster = $this->getEvent()->getRouteParam('roster_name'); $bWithId = $this->getEvent()->getQueryParam('withids', 0); $iSpe = $this->getEvent()->getQueryParam('spe', -1); $key = $this->getRequestKey('APIRtK-loot', array($sRoster, $bWithId, $iSpe)); if ($this->cache->hasItem($key) === true) { return $this->cache->getItem($key); } $oTabRoster = $this->getTableRoster()->selectBy(array("nom" => $sRoster)); if (!$oTabRoster) { return new LogApiProblem(404, sprintf($this->_getServTranslator()->translate("Le roster [ %s ] n'a pas été trouvé."), $sRoster), $this->_getServTranslator()->translate("Not Found"), $this->_getServTranslator()->translate("Personnage / Serveur inconnu"), array(), $this->_service); } $oResult = new LootRosterEntity(); $oResult->setId($oTabRoster->getIdRoster()); $oResult->setNom($sRoster); $aItemsPersonnage = $this->getTableItemPersonnageRaid()->getLootStatDuRoster($sRoster, $bWithId, $iSpe); $oResult->setItems($aItemsPersonnage); $this->addItem($key, $oResult); return $oResult; } catch (\Exception $ex) { return \Core\Util\ParseException::tranformeExceptionToApiProblem($ex, $this->_service); } }
/** * Fetch a resource * * @param mixed $id * @return LogApiProblem|mixed */ public function fetch($id) { try { $sNom = $this->getEvent()->getRouteParam('character_id'); $sServer = $this->getEvent()->getRouteParam('api-character-server'); $key = $this->getRequestKey('APIBlizzard-character', array($sNom, $sServer)); if ($this->cache->hasItem($key) === true) { return $this->cache->getItem($key); } $aPost = array('serveur' => $sServer, 'nom' => $sNom); $aOptionBnet = array(); $oPersonnage = $this->getTablePersonnage()->importPersonnage($aPost, null, $aOptionBnet); $oReturn = $oPersonnage->jsonSerialize(); $oReturn['race'] = $this->_tableRace->findRow($oReturn['race'])->getNom(); $oReturn['class'] = $this->_tableClasses->findRow($oReturn['class'])->getNom(); $oReturn['gender'] = $oReturn['gender'] == 0 ? "Male" : "Female"; $this->addItem($key, $oReturn); return $oReturn; } catch (\Exception $ex) { return \Core\Util\ParseException::tranformeExceptionToApiProblem($ex, $this->_service); } }