From 1e70cface0996d86df5edac7fd7bf22bdd7e3f0b Mon Sep 17 00:00:00 2001 From: Markus Frosch Date: Fri, 14 Oct 2016 11:08:47 +0200 Subject: [PATCH] IcingaObject(Legacy): Render directly added groups refs #12919 --- library/Director/Objects/IcingaObject.php | 14 +++++++++++++- library/Director/Objects/IcingaObjectGroups.php | 13 +++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/library/Director/Objects/IcingaObject.php b/library/Director/Objects/IcingaObject.php index f9c37b99..b4203565 100644 --- a/library/Director/Objects/IcingaObject.php +++ b/library/Director/Objects/IcingaObject.php @@ -1863,6 +1863,18 @@ abstract class IcingaObject extends DbObject implements IcingaConfigRenderer } } + /** + * @return string + */ + protected function renderLegacyGroups() + { + if ($this->supportsGroups()) { + return $this->groups()->toLegacyConfigString(); + } else { + return ''; + } + } + /** * @return string */ @@ -2009,7 +2021,7 @@ abstract class IcingaObject extends DbObject implements IcingaConfigRenderer //$this->renderRanges(), //$this->renderArguments(), //$this->renderRelatedSets(), - //$this->renderGroups(), + $this->renderLegacyGroups(), //$this->renderMultiRelations(), //$this->renderCustomExtensions(), //$this->renderCustomVars(), diff --git a/library/Director/Objects/IcingaObjectGroups.php b/library/Director/Objects/IcingaObjectGroups.php index 8ec06c22..e78c31a9 100644 --- a/library/Director/Objects/IcingaObjectGroups.php +++ b/library/Director/Objects/IcingaObjectGroups.php @@ -9,6 +9,7 @@ use Countable; use Icinga\Module\Director\Db\Cache\PrefetchCache; use Icinga\Module\Director\IcingaConfig\IcingaConfigRenderer; use Icinga\Module\Director\IcingaConfig\IcingaConfigHelper as c; +use Icinga\Module\Director\IcingaConfig\IcingaLegacyConfigHelper as c1; class IcingaObjectGroups implements Iterator, Countable, IcingaConfigRenderer { @@ -344,6 +345,18 @@ class IcingaObjectGroups implements Iterator, Countable, IcingaConfigRenderer return c::renderKeyValue('groups', c::renderArray($groups)); } + public function toLegacyConfigString() + { + $groups = array_keys($this->groups); + + if (empty($groups)) { + return ''; + } + + $type = $this->object->getLegacyObjectType(); + return c1::renderKeyValue($type.'groups', c1::renderArray($groups)); + } + public function __toString() { try {