IcingaObject(Legacy): Render directly added groups

refs #12919
This commit is contained in:
Markus Frosch 2016-10-14 11:08:47 +02:00
parent a8179507dc
commit 1e70cface0
2 changed files with 26 additions and 1 deletions

View File

@ -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 * @return string
*/ */
@ -2009,7 +2021,7 @@ abstract class IcingaObject extends DbObject implements IcingaConfigRenderer
//$this->renderRanges(), //$this->renderRanges(),
//$this->renderArguments(), //$this->renderArguments(),
//$this->renderRelatedSets(), //$this->renderRelatedSets(),
//$this->renderGroups(), $this->renderLegacyGroups(),
//$this->renderMultiRelations(), //$this->renderMultiRelations(),
//$this->renderCustomExtensions(), //$this->renderCustomExtensions(),
//$this->renderCustomVars(), //$this->renderCustomVars(),

View File

@ -9,6 +9,7 @@ use Countable;
use Icinga\Module\Director\Db\Cache\PrefetchCache; use Icinga\Module\Director\Db\Cache\PrefetchCache;
use Icinga\Module\Director\IcingaConfig\IcingaConfigRenderer; use Icinga\Module\Director\IcingaConfig\IcingaConfigRenderer;
use Icinga\Module\Director\IcingaConfig\IcingaConfigHelper as c; use Icinga\Module\Director\IcingaConfig\IcingaConfigHelper as c;
use Icinga\Module\Director\IcingaConfig\IcingaLegacyConfigHelper as c1;
class IcingaObjectGroups implements Iterator, Countable, IcingaConfigRenderer class IcingaObjectGroups implements Iterator, Countable, IcingaConfigRenderer
{ {
@ -344,6 +345,18 @@ class IcingaObjectGroups implements Iterator, Countable, IcingaConfigRenderer
return c::renderKeyValue('groups', c::renderArray($groups)); 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() public function __toString()
{ {
try { try {