IcingaObject: Do not invalidate templateResolver on every setImports()
Do not clear templateResolver, but refresh current object with its "new" parents. refs #11803
This commit is contained in:
parent
22802114ac
commit
86d2f317ee
|
@ -1005,10 +1005,6 @@ abstract class IcingaObject extends DbObject implements IcingaConfigRenderer
|
|||
public function invalidateResolveCache()
|
||||
{
|
||||
$this->resolveCache = array();
|
||||
if ($this->templateResolver) {
|
||||
$this->templateResolver()->clearCache();
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
|
|
@ -167,6 +167,7 @@ class IcingaObjectImports implements Iterator, Countable, IcingaConfigRenderer
|
|||
protected function refreshIndex()
|
||||
{
|
||||
$this->idx = array_keys($this->imports);
|
||||
$this->object->templateResolver()->refreshObject($this->object);
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
|
|
@ -9,10 +9,13 @@ use Icinga\Module\Director\Exception\NestingError;
|
|||
// TODO: move the 'type' layer to another class
|
||||
class IcingaTemplateResolver
|
||||
{
|
||||
/** @var IcingaObject */
|
||||
protected $object;
|
||||
|
||||
/** @var Db */
|
||||
protected $connection;
|
||||
|
||||
/** @var \Zend_Db_Adapter_Abstract */
|
||||
protected $db;
|
||||
|
||||
protected $type;
|
||||
|
@ -162,6 +165,11 @@ class IcingaTemplateResolver
|
|||
return $this->resolveParentIds();
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: unfinished and not used currently
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function listResolvedParentNames()
|
||||
{
|
||||
$this->requireTemplates();
|
||||
|
@ -365,4 +373,14 @@ class IcingaTemplateResolver
|
|||
unset($this->db);
|
||||
unset($this->object);
|
||||
}
|
||||
|
||||
public function refreshObject(IcingaObject $object)
|
||||
{
|
||||
$parentNames = $object->imports;
|
||||
self::$nameIdx[$object->object_name] = $parentNames;
|
||||
if ($object->hasBeenLoadedFromDb()) {
|
||||
self::$idIdx[$object->getId()] = $this->getIdsForNames($parentNames);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue