IcingaObjectImports: fix check for modifications

refs #1062
This commit is contained in:
Thomas Gelf 2017-08-21 21:36:21 +02:00
parent 8402f58610
commit a092c5d79e
3 changed files with 21 additions and 3 deletions

View File

@ -19,7 +19,6 @@ use Icinga\Module\Director\IcingaConfig\IcingaConfigRenderer;
use Icinga\Module\Director\IcingaConfig\IcingaConfigHelper as c;
use Icinga\Module\Director\IcingaConfig\IcingaLegacyConfigHelper as c1;
use Icinga\Module\Director\Repository\IcingaTemplateRepository;
use Icinga\Module\Director\Resolver\TemplateTree;
abstract class IcingaObject extends DbObject implements IcingaConfigRenderer
{
@ -871,6 +870,10 @@ abstract class IcingaObject extends DbObject implements IcingaConfigRenderer
return $this->listImportNames();
}
/**
* @deprecated This should no longer be in use
* @return IcingaTemplateResolver
*/
public function templateResolver()
{
if ($this->templateResolver === null) {
@ -2437,7 +2440,7 @@ abstract class IcingaObject extends DbObject implements IcingaConfigRenderer
if ($object->supportsCustomVars()) {
$vars = $object->getVars();
$object->vars = array();
$object->set('vars', []);
}
$this->setProperties((array) $object->toPlainObject(null, true));

View File

@ -274,7 +274,8 @@ class IcingaObjectImports implements Iterator, Countable, IcingaConfigRenderer
{
// $resolver = $this->object->templateResolver();
// $this->objects = $resolver->fetchParents();
$this->objects = IcingaTemplateRepository::instanceByObject($this->object)->getTemplatesFor($this->object);
$this->objects = IcingaTemplateRepository::instanceByObject($this->object)
->getTemplatesIndexedByNameFor($this->object);
if (empty($this->objects)) {
$this->imports = array();
} else {

View File

@ -50,6 +50,20 @@ class IcingaTemplateRepository
return $templates;
}
/**
* @param IcingaObject $object
* @return IcingaObject[]
*/
public function getTemplatesIndexedByNameFor(IcingaObject $object)
{
$templates = [];
foreach ($this->getTemplatesFor($object) as $template) {
$templates[$template->getObjectName()] = $template;
}
return $templates;
}
public function persistImportNames()
{
}