mirror of
https://github.com/Icinga/icingadb-web.git
synced 2026-05-28 04:36:06 -04:00
CompatObject: Handle dynamic property access more like the MonitoredObject
This commit is contained in:
parent
2f23a60219
commit
60434fe15b
1 changed files with 31 additions and 19 deletions
|
|
@ -105,6 +105,15 @@ trait CompatObject
|
|||
|
||||
public function __get($name)
|
||||
{
|
||||
if (property_exists($this, $name)) {
|
||||
if ($this->$name === null) {
|
||||
$fetchMethod = 'fetch' . ucfirst($name);
|
||||
$this->$fetchMethod();
|
||||
}
|
||||
|
||||
return $this->$name;
|
||||
}
|
||||
|
||||
if (preg_match('/^_(host|service)_(.+)/i', $name, $matches)) {
|
||||
switch (strtolower($matches[1])) {
|
||||
case $this->type:
|
||||
|
|
@ -125,29 +134,32 @@ trait CompatObject
|
|||
return null; // Unknown custom variables MUST NOT throw an error
|
||||
}
|
||||
|
||||
if (isset($this->legacyColumns[$name])) {
|
||||
$name = $this->legacyColumns[$name];
|
||||
}
|
||||
|
||||
if (is_array($name)) {
|
||||
$value = $this->object;
|
||||
|
||||
do {
|
||||
$col = array_shift($name);
|
||||
$value = $value->$col;
|
||||
} while (! empty($name));
|
||||
} elseif (property_exists($this, $name)) {
|
||||
if ($this->$name === null) {
|
||||
$fetchMethod = 'fetch' . ucfirst($name);
|
||||
$this->$fetchMethod();
|
||||
if (! isset($this->legacyColumns[$name]) && ! $this->object->hasProperty($name)) {
|
||||
if (isset($this->customvars[$name])) {
|
||||
return $this->customvars[$name];
|
||||
}
|
||||
|
||||
return $this->$name;
|
||||
} else {
|
||||
$value = $this->object->$name;
|
||||
if (substr($name, 0, strlen($this->prefix)) !== $this->prefix) {
|
||||
$name = $this->prefix . $name;
|
||||
}
|
||||
}
|
||||
|
||||
return $value;
|
||||
if (isset($this->legacyColumns[$name])) {
|
||||
$name = $this->legacyColumns[$name];
|
||||
|
||||
if (is_array($name)) {
|
||||
$value = $this->object;
|
||||
|
||||
do {
|
||||
$col = array_shift($name);
|
||||
$value = $value->$col;
|
||||
} while (! empty($name));
|
||||
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->object->$name;
|
||||
}
|
||||
|
||||
public function __isset($name)
|
||||
|
|
|
|||
Loading…
Reference in a new issue