diff --git a/library/Director/Objects/IcingaServiceSet.php b/library/Director/Objects/IcingaServiceSet.php index 371e88c8..12c6f39a 100644 --- a/library/Director/Objects/IcingaServiceSet.php +++ b/library/Director/Objects/IcingaServiceSet.php @@ -3,6 +3,7 @@ namespace Icinga\Module\Director\Objects; use Icinga\Data\Filter\Filter; +use Icinga\Exception\IcingaException; use Icinga\Module\Director\IcingaConfig\IcingaConfig; @@ -43,6 +44,26 @@ class IcingaServiceSet extends IcingaObject return true; } + protected function setKey($key) + { + if (is_int($key)) { + $this->id = $key; + } elseif (is_string($key)) { + $keyComponents = preg_split('~!~', $key); + if (count($keyComponents) === 1) { + $this->set('object_name', $keyComponents[0]); + $this->set('object_type', 'template'); + } + else { + throw new IcingaException('Can not parse key: %s', $key); + } + } else { + return parent::setKey($key); + } + + return $this; + } + /** * @return IcingaService[] */