mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-07-24 14:24:42 +02:00
IcingaObject: add new resolving helper methods
This for example allows to get a single inherited var and their origin
This commit is contained in:
parent
f527e31b14
commit
0d930efb46
@ -421,7 +421,6 @@ abstract class IcingaObject extends DbObject implements IcingaConfigRenderer
|
||||
$this->resolveUnresolvedRelatedProperties();
|
||||
|
||||
if ($this->supportsCustomVars() && $this->vars !== null && $this->vars()->hasBeenModified()) {
|
||||
//var_dump($this->vars()); exit;
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -798,6 +797,51 @@ abstract class IcingaObject extends DbObject implements IcingaConfigRenderer
|
||||
return $default;
|
||||
}
|
||||
|
||||
public function getInheritedProperty($key, $default = null)
|
||||
{
|
||||
if (array_key_exists($key, $this->unresolvedRelatedProperties)) {
|
||||
$this->resolveUnresolvedRelatedProperty($key);
|
||||
$this->invalidateResolveCache();
|
||||
}
|
||||
|
||||
$properties = $this->getInheritedProperties();
|
||||
if (property_exists($properties, $key)) {
|
||||
return $properties->$key;
|
||||
}
|
||||
|
||||
return $default;
|
||||
}
|
||||
|
||||
public function getInheritedVar($varname)
|
||||
{
|
||||
try {
|
||||
$vars = $this->getInheritedVars();
|
||||
} catch (NestingError $e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (property_exists($vars, $varname)) {
|
||||
return $vars->$varname;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public function getOriginForVar($varname)
|
||||
{
|
||||
try {
|
||||
$origins = $this->getOriginsVars();
|
||||
} catch (NestingError $e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (property_exists($origins, $varname)) {
|
||||
return $origins->$varname;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public function getResolvedProperties()
|
||||
{
|
||||
return $this->getResolved('Properties');
|
||||
|
Loading…
x
Reference in New Issue
Block a user