Пример #1
0
 /**
  * Gets the soldier information so we can update the clantag and name if needed
  * @return mixed
  */
 private function getSoldierAndUpdate()
 {
     // Generate URI for request
     $uri = sprintf($this->uris[$this->game]['soldier'], $this->game, $this->personaUserID, $this->personaID);
     // Send request
     $results = $this->sendRequest($uri);
     $oldName = $this->player->SoldierName;
     $oldClan = $this->player->ClanTag;
     $persona = $results['context']['statsPersona'];
     if ($this->player->SoldierName != $persona['personaName']) {
         $this->player->SoldierName = $persona['personaName'];
     }
     if ($this->player->ClanTag != $persona['clanTag']) {
         $this->player->ClanTag = empty($persona['clanTag']) ? null : $persona['clanTag'];
     }
     if ($oldName != $persona['personaName'] || $oldClan != $persona['clanTag']) {
         Cache::forget(sprintf('api.player.%u', $this->player->PlayerID));
         Cache::forget(sprintf('player.%u', $this->player->PlayerID));
         $this->player->save();
     }
     return $this;
 }
Пример #2
0
 /**
  * Gets the soldier information so we can update the clan tag and name if needed
  *
  * @return mixed
  * @throws BattlelogException
  */
 private function getSoldierAndUpdate()
 {
     // Generate URI for request
     $uri = sprintf($this->uris[$this->game]['soldier'], $this->game, $this->personaUserID, $this->personaID);
     // Send request
     $results = $this->sendRequest($uri);
     $oldName = $this->player->SoldierName;
     $oldClan = $this->player->ClanTag;
     if (!array_key_exists('statsPersona', $results['context'])) {
         throw new BattlelogException(500, sprintf('Could not retrieve stats for %s.', $oldName));
     }
     $persona = $results['context']['statsPersona'];
     if ($oldName != $persona['personaName']) {
         $this->player->SoldierName = $persona['personaName'];
     }
     if ($oldClan != $persona['clanTag']) {
         $this->player->ClanTag = empty($persona['clanTag']) ? null : $persona['clanTag'];
     }
     if ($oldName != $persona['personaName'] || $oldClan != $persona['clanTag']) {
         $this->player->forget();
         $this->player->save();
     }
     return $this;
 }