mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-07-29 00:34:05 +02:00
IcingaObject: fix resolution of lazy-loaded rels
This commit is contained in:
parent
2826408c72
commit
aee62754ce
@ -175,8 +175,31 @@ abstract class IcingaObject extends DbObject implements IcingaConfigRenderer
|
|||||||
return $this->supportsApplyRules;
|
return $this->supportsApplyRules;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function resolveUnresolvedRelatedProperties()
|
||||||
|
{
|
||||||
|
foreach ($this->unresolvedRelatedProperties as $name => $p) {
|
||||||
|
$this->resolveUnresolvedRelatedProperty($name);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function resolveUnresolvedRelatedProperty($name)
|
||||||
|
{
|
||||||
|
$class = $this->getRelationClass($name);
|
||||||
|
$object = $class::load(
|
||||||
|
$this->unresolvedRelatedProperties[$name],
|
||||||
|
$this->connection
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->$key = $object->id;
|
||||||
|
unset($this->unresolvedRelatedProperties[$name]);
|
||||||
|
}
|
||||||
|
|
||||||
public function hasBeenModified()
|
public function hasBeenModified()
|
||||||
{
|
{
|
||||||
|
$this->resolveUnresolvedRelatedProperties();
|
||||||
|
|
||||||
if ($this->supportsCustomVars() && $this->vars !== null && $this->vars()->hasBeenModified()) {
|
if ($this->supportsCustomVars() && $this->vars !== null && $this->vars()->hasBeenModified()) {
|
||||||
//var_dump($this->vars()); exit;
|
//var_dump($this->vars()); exit;
|
||||||
return true;
|
return true;
|
||||||
@ -213,13 +236,7 @@ abstract class IcingaObject extends DbObject implements IcingaConfigRenderer
|
|||||||
$short = substr($key, 0, -3);
|
$short = substr($key, 0, -3);
|
||||||
if ($this->hasRelation($short)) {
|
if ($this->hasRelation($short)) {
|
||||||
if (array_key_exists($short, $this->unresolvedRelatedProperties)) {
|
if (array_key_exists($short, $this->unresolvedRelatedProperties)) {
|
||||||
$class = $this->getRelationClass($short);
|
$this->resolveUnresolvedRelatedProperty($short);
|
||||||
$object = $class::load(
|
|
||||||
$this->unresolvedRelatedProperties[$short],
|
|
||||||
$this->connection
|
|
||||||
);
|
|
||||||
|
|
||||||
$this->$key = $object->id;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user