CustomVariables: readability, IDE hints

This commit is contained in:
Thomas Gelf 2018-02-25 17:58:11 +01:00
parent feb80480ea
commit 22eb5911f0
3 changed files with 9 additions and 8 deletions

View File

@ -33,7 +33,7 @@ class DirectorDatafieldForm extends DirectorObjectForm
}
}
return parent::onRequest();
parent::onRequest();
}
protected function askForVariableDeletion($varname, $cnt)

View File

@ -87,6 +87,10 @@ abstract class CustomVariable implements IcingaConfigRenderer
return $this->key;
}
/**
* @param $value
* @return $this
*/
abstract public function setValue($value);
abstract public function getValue();

View File

@ -42,15 +42,12 @@ class CustomVariables implements Iterator, Countable, IcingaConfigRenderer
$parts = array();
$where = $db->quoteInto('varname = ?', $varname);
foreach (static::$allTables as $table) {
$parts[] = sprintf(
'SELECT COUNT(*) as cnt FROM ' . $table . ' WHERE %s',
$where
);
$parts[] = "SELECT COUNT(*) as cnt FROM $table WHERE $where";
}
$query = 'SELECT SUM(cnt) AS cnt FROM ('
. implode(' UNION ALL ', $parts)
. ') sub';
$sub = implode(' UNION ALL ', $parts);
$query = "SELECT SUM(sub.cnt) AS cnt FROM ($sub) sub";
return (int) $db->fetchOne($query);
}