Files
pathfinder/app/main/lib/ccpclient.php
Exodus4D a8edf39697 - new "logging" system for map/system/signature/connection changes, closed #271
- new map change log to Slack channel
- new "rally point" logging to Slack channel
- new "rally point" poke options (e.g. custom message), closed #295
- new log options for WebSocket installations
- added ship "mass" logging (backend only), #313
- added map logging to Slack, #326
- added "ESI error rate" limit detection
- added "Monolog" as new logging library (Composer dependency)
- added "Swiftmailer" as new eMail library (Composer dependency)
- added Support for Redis session hander (performance boost)
- improved character select panels (visible "online" status)
- improved "activity logging" (more DB columns added to check)
- improved eMail logging (HTML template support)
- improved "delete map" now become "inactive" for some days before delete
- improved character logout handling
- improved /setup page for DB bootstrap (new button for DB create if not exists)
- fixed broken ship tracking (ship name re-added)
- fixed broken ship tracking for multiple chars on different browser tabs
- fixed broken cursor coordinates, closed #518
- fixed null pointer "charactermodel.php->isActive():925" closed #529
- fixed broken "scroll offset", closed #533 closed #534
- Updated "validation" library JS v0.10.1 -> v0.11.9
- Updated ORM Mapper _Cortex_ v1.5.0-dev -> v1.5.0
- and many more....
2017-10-22 17:58:34 +02:00

90 lines
2.6 KiB
PHP

<?php
/**
* Created by PhpStorm.
* User: Exodus4D
* Date: 26.03.2017
* Time: 19:17
*/
namespace Lib;
use controller\LogController;
use \Exodus4D\ESI\ESI as ApiClient;
class CcpClient extends \Prefab {
private $apiClient;
public function __construct(\Base $f3){
$this->apiClient = $this->getClient($f3);
$f3->set('ccpClient', $this);
}
/**
* get ApiClient instance
* @param \Base $f3
* @return ApiClient|null
*/
protected function getClient(\Base $f3){
$client = null;
if(class_exists(ApiClient::class)){
$client = new ApiClient();
$client->setUrl( Config::getEnvironmentData('CCP_ESI_URL') );
$client->setDatasource( Config::getEnvironmentData('CCP_ESI_DATASOURCE') );
$client->setUserAgent($this->getUserAgent());
$client->setDebugLevel($f3->get('DEBUG'));
}else{
LogController::getLogger('ERROR')->write(sprintf(Config::ERROR_CLASS_NOT_EXISTS_COMPOSER, ApiClient::class));
}
return $client;
}
/**
* @return string
*/
protected function getUserAgent(){
$userAgent = '';
$userAgent .= Config::getPathfinderData('name');
$userAgent .= ' - ' . Config::getPathfinderData('version');
$userAgent .= ' | ' . Config::getPathfinderData('contact');
$userAgent .= ' (' . $_SERVER['SERVER_NAME'] . ')';
return $userAgent;
}
/**
* get error msg for undefined method in ApiClient() class
* @param $method
* @return string
*/
protected function getMissingMethodError($method){
return "Method '" . $method . "()' not found in class '" . get_class($this->apiClient) . "'. -> Check installed Composer package version.'";
}
/**
* call request API data
* @param $name
* @param $arguments
* @return array|mixed
*/
public function __call($name, $arguments){
$return = [];
if(is_object($this->apiClient)){
if( method_exists($this->apiClient, $name) ){
$return = call_user_func_array([$this->apiClient, $name], $arguments);
}else{
LogController::getLogger('ERROR')->write($this->getMissingMethodError($name));
\Base::instance()->error(501, $this->getMissingMethodError($name));
}
}else{
LogController::getLogger('ERROR')->write(sprintf(Config::ERROR_CLASS_NOT_EXISTS_COMPOSER, ApiClient::class));
\Base::instance()->error(501, sprintf(Config::ERROR_CLASS_NOT_EXISTS_COMPOSER, ApiClient::class));
}
return $return;
}
}