- Added docking information for "Structures" ( e.g. Citadels)

- Added system environment var check to /setup page
- Added new ESI scope "read_structures.v1"
This commit is contained in:
Mark Friedrich
2017-10-31 14:40:02 +01:00
parent a8edf39697
commit 444d54d642
18 changed files with 450 additions and 80 deletions

View File

@@ -35,4 +35,51 @@ abstract class BasicUniverseModel extends BasicModel {
return $class;
}
/**
* load data from API into $this and save $this
* @param int $id
* @param string $accessToken
* @param array $additionalOptions
*/
abstract protected function loadData(int $id, string $accessToken = '', array $additionalOptions = []);
/**
* load object by $id
* -> if $id not exists in DB -> query API
* @param int $id
* @param string $accessToken
* @param array $additionalOptions
*/
public function loadById(int $id, string $accessToken = '', array $additionalOptions = []){
/**
* @var $model self
*/
$model = $this->getById($id);
if($model->isOutdated()){
$model->loadData($id, $accessToken, $additionalOptions);
}
}
/**
* checks whether data is outdated and should be refreshed
* @return bool
*/
protected function isOutdated(): bool {
$outdated = true;
if(!$this->dry()){
$timezone = $this->getF3()->get('getTimeZone')();
$currentTime = new \DateTime('now', $timezone);
$updateTime = \DateTime::createFromFormat(
'Y-m-d H:i:s',
$this->updated,
$timezone
);
$interval = $updateTime->diff($currentTime);
if($interval->days < self::CACHE_MAX_DAYS ){
$outdated = false;
}
}
return $outdated;
}
}