various: formatting, cleanup

This commit is contained in:
Thomas Gelf 2020-01-10 12:33:54 +01:00
parent d795ad3c8e
commit 2ef30f5f12
5 changed files with 27 additions and 15 deletions

View File

@ -35,7 +35,14 @@ class DashboardController extends ActionController
$this->setAutorefreshInterval(10);
}
$mainDashboards = ['Objects', 'Alerts', 'Automation', 'Deployment', 'Director', 'Data'];
$mainDashboards = [
'Objects',
'Alerts',
'Automation',
'Deployment',
'Director',
'Data',
];
$this->setTitle($this->translate('Icinga Director - Main Dashboard'));
$names = $this->params->getValues('name', $mainDashboards);
if (! $this->params->has('name')) {

View File

@ -15,10 +15,10 @@ class IcingaObjectFilterRenderer
/** @var IcingaObjectQuery */
protected $query;
protected $columnMap = array(
protected $columnMap = [
'host.name' => 'host.object_name',
'service.name' => 'service.object_name',
);
];
public function __construct(Filter $filter, IcingaObjectQuery $query)
{

View File

@ -70,7 +70,7 @@ class IcingaObjectQuery
if (! $this->hasJoinedVar($name)) {
$type = $this->type;
$alias = $this->safeVarAlias($name);
$varAlias = $alias . '_v';
$varAlias = "v_$alias";
// TODO: optionally $varRelation = sprintf('icinga_%s_resolved_var', $type);
$varRelation = sprintf('icinga_%s_var', $type);
$idCol = sprintf('%s.%s_id', $alias, $type);
@ -97,6 +97,12 @@ class IcingaObjectQuery
return $this;
}
// Debug only
public function getSql()
{
return (string) $this->baseQuery;
}
public function listNames()
{
return $this->db->fetchCol(
@ -141,7 +147,6 @@ class IcingaObjectQuery
*/
public function getAliasForRequiredFilterColumn($column)
{
$dot = strpos($column, '.');
list($key, $sub) = $this->splitFilterKey($column);
if ($sub === null) {
return $key;
@ -169,9 +174,9 @@ class IcingaObjectQuery
{
$dot = strpos($key, '.');
if ($dot === false) {
return array($key, null);
return [$key, null];
} else {
return array(substr($key, 0, $dot), substr($key, $dot + 1));
return [substr($key, 0, $dot), substr($key, $dot + 1)];
}
}

View File

@ -10,10 +10,10 @@ class IcingaFlatVar extends DbObject
{
protected $table = 'icinga_flat_var';
protected $keyName = array(
'checksum',
protected $keyName = [
'var_checksum',
'flatname_checksum'
);
];
protected $defaultProperties = [
'var_checksum' => null,
@ -39,18 +39,18 @@ class IcingaFlatVar extends DbObject
public static function forCustomVar(CustomVariable $var, Db $db)
{
$flat = array();
$flat = [];
$varSum = $var->checksum();
$var->flatten($flat, $var->getKey());
$flatVars = array();
$flatVars = [];
foreach ($flat as $name => $value) {
$flatVar = static::create(array(
$flatVar = static::create([
'var_checksum' => $varSum,
'flatname_checksum' => sha1($name, true),
'flatname' => $name,
'flatvalue' => $value,
), $db);
], $db);
$flatVar->store();
$flatVars[] = $flatVar;

View File

@ -29,7 +29,7 @@ class IcingaVar extends DbObject
];
/**
* @param CustomVariable $var
* @param CustomVariable $customVar
* @param Db $db
*
* @return static