mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-07-28 08:14:04 +02:00
ImportsourceHookTable: apply modifiers on preview
This commit is contained in:
parent
3de4869813
commit
33dd977214
@ -68,11 +68,47 @@ class ImportsourceHookTable extends QuickTable
|
|||||||
}
|
}
|
||||||
|
|
||||||
$this->dataCache = $query->fetchAll();
|
$this->dataCache = $query->fetchAll();
|
||||||
|
$this->applyModifiers();
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->dataCache;
|
return $this->dataCache;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function applyModifiers()
|
||||||
|
{
|
||||||
|
$modifiers = $this->source->fetchRowModifiers();
|
||||||
|
if (empty($modifiers)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$propertyModifiers = array();
|
||||||
|
|
||||||
|
|
||||||
|
foreach ($modifiers as $mod) {
|
||||||
|
if (! array_key_exists($mod->property_name, $propertyModifiers)) {
|
||||||
|
$propertyModifiers[$mod->property_name] = array();
|
||||||
|
}
|
||||||
|
$obj = new $mod->provider_class;
|
||||||
|
$obj->setSettings($mod->getSettings());
|
||||||
|
$propertyModifiers[$mod->property_name][] = $obj;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($this->dataCache as & $row) {
|
||||||
|
foreach ($propertyModifiers as $key => $mods) {
|
||||||
|
foreach ($mods as $mod) {
|
||||||
|
if (is_array($row->$key)) {
|
||||||
|
foreach ($row->$key as & $k) {
|
||||||
|
$k = $mod->transform($k);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$row->$key = $mod->transform($row->$key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function getBaseQuery()
|
public function getBaseQuery()
|
||||||
{
|
{
|
||||||
$ds = new ArrayDatasource($this->sourceHook()->fetchData());
|
$ds = new ArrayDatasource($this->sourceHook()->fetchData());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user