IcingaScheduledDowntime: render object header

This commit is contained in:
Thomas Gelf 2018-06-15 12:10:44 +02:00
parent 6f790dd118
commit e7fc4d3009
1 changed files with 25 additions and 2 deletions

View File

@ -2,6 +2,9 @@
namespace Icinga\Module\Director\Objects;
use Icinga\Exception\ConfigurationError;
use Icinga\Module\Director\IcingaConfig\IcingaConfigHelper as c;
class IcingaScheduledDowntime extends IcingaObject
{
protected $table = 'icinga_scheduled_downtime';
@ -53,10 +56,30 @@ class IcingaScheduledDowntime extends IcingaObject
return '';
}
/**
* @return string
* @throws ConfigurationError
*/
protected function renderObjectHeader()
{
return parent::renderObjectHeader()
. ' import "legacy-timeperiod"' . "\n";
if ($this->isApplyRule()) {
if (($to = $this->get('apply_to')) === null) {
throw new ConfigurationError(
'Applied notification "%s" has no valid object type',
$this->getObjectName()
);
}
return sprintf(
"%s %s %s to %s {\n",
$this->getObjectTypeName(),
$this->getType(),
c::renderString($this->getObjectName()),
ucfirst($to)
);
} else {
return parent::renderObjectHeader();
}
}
public function isActive($now = null)