IcingaTimePeriod: fix config errors at deploy time

This commit is contained in:
Thomas Gelf 2016-03-21 13:35:00 +01:00
parent ce7b6031ff
commit c7cba66c83
2 changed files with 30 additions and 4 deletions

View File

@ -38,10 +38,20 @@ class IcingaTimePeriodForm extends DirectorObjectForm
'description' => $this->translate('the display name')
));
$this->addElement('text', 'update_method', array(
'label' => $this->translate('Update Method'),
'description' => $this->translate('the update method'),
));
if ($this->isTemplate()) {
$this->addElement('text', 'update_method', array(
'label' => $this->translate('Update Method'),
'description' => $this->translate('the update method'),
'value' => 'LegacyTimePeriod',
));
} else {
// TODO: I'd like to skip this for objects inheriting from a template
// with a defined update_method. However, unfortunately it's too
// early for $this->object()->getResolvedProperty('update_method').
// Should be fixed.
$this->addHidden('update_method', 'LegacyTimePeriod');
}
$this->addImportsElement();

View File

@ -2,6 +2,8 @@
namespace Icinga\Module\Director\Objects;
use Icinga\Module\Director\IcingaConfig\IcingaConfigHelper as c;
class IcingaTimePeriod extends IcingaObject
{
protected $table = 'icinga_timeperiod';
@ -19,4 +21,18 @@ class IcingaTimePeriod extends IcingaObject
protected $supportsImports = true;
protected $supportsRanges = true;
/**
* Render update property
*
* Avoid complaints for method names with underscore:
* @codingStandardsIgnoreStart
*
* @return string
*/
public function renderUpdate_method()
{
// @codingStandardsIgnoreEnd
return c::renderKeyValue('update', $this->update_method);
}
}