- fixed DB setup error: "`system`.`description` can´t have a default value", closed #701 - upgraded "lazyload" js lib `v1.9.5` → `v1.9.7` - upgraded multiple 3rd party NPM dependencies for Gulp build
81 lines
1.9 KiB
PHP
81 lines
1.9 KiB
PHP
<?php
|
|
/**
|
|
* Created by PhpStorm.
|
|
* User: exodu
|
|
* Date: 22.09.2017
|
|
* Time: 19:05
|
|
*/
|
|
|
|
namespace lib\logging;
|
|
|
|
use lib\Config;
|
|
use Model\CharacterModel;
|
|
|
|
abstract class AbstractCharacterLog extends AbstractChannelLog{
|
|
|
|
/**
|
|
* @var CharacterModel
|
|
*/
|
|
private $character = null;
|
|
|
|
public function __construct(string $action, array $objectData){
|
|
parent::__construct($action, $objectData);
|
|
|
|
// add log processor -> remove $channelData from log
|
|
$processorAddThumbData = function($record){
|
|
$record['extra']['thumb']['url'] = $this->getThumbUrl();
|
|
return $record;
|
|
};
|
|
|
|
// init processorConfig. IMPORTANT: first processor gets executed at the end!
|
|
$this->processorConfig = ['addThumbData' => $processorAddThumbData] + $this->processorConfig;
|
|
}
|
|
|
|
/**
|
|
* CharacterModel $character
|
|
* @param CharacterModel $character
|
|
* @return LogInterface
|
|
*/
|
|
public function setCharacter(CharacterModel $character): LogInterface{
|
|
$this->character = $character;
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* @return CharacterModel
|
|
*/
|
|
public function getCharacter(): CharacterModel{
|
|
return $this->character;
|
|
}
|
|
|
|
/**
|
|
* @return array
|
|
*/
|
|
public function getData() : array{
|
|
$data = parent::getData();
|
|
|
|
if(is_object($character = $this->getCharacter())){
|
|
$characterData['character'] = [
|
|
'id' => $character->_id,
|
|
'name' => $character->name
|
|
];
|
|
$data = $characterData + $data;
|
|
}
|
|
|
|
return $data;
|
|
}
|
|
|
|
/**
|
|
* get character thumbnailUrl
|
|
* @return string
|
|
*/
|
|
protected function getThumbUrl(): string {
|
|
$url = '';
|
|
if(is_object($character = $this->getCharacter())){
|
|
$url = Config::getPathfinderData('api.ccp_image_server') . '/Character/' . $character->_id . '_128.jpg';
|
|
}
|
|
|
|
return $url;
|
|
}
|
|
|
|
} |