From c7cba66c83caeb38440c5d2e6abfb7809fa51964 Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Mon, 21 Mar 2016 13:35:00 +0100 Subject: [PATCH] IcingaTimePeriod: fix config errors at deploy time --- application/forms/IcingaTimePeriodForm.php | 18 ++++++++++++++---- library/Director/Objects/IcingaTimePeriod.php | 16 ++++++++++++++++ 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/application/forms/IcingaTimePeriodForm.php b/application/forms/IcingaTimePeriodForm.php index d1cd8535..01101f27 100644 --- a/application/forms/IcingaTimePeriodForm.php +++ b/application/forms/IcingaTimePeriodForm.php @@ -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(); diff --git a/library/Director/Objects/IcingaTimePeriod.php b/library/Director/Objects/IcingaTimePeriod.php index 232f9448..d69707fa 100644 --- a/library/Director/Objects/IcingaTimePeriod.php +++ b/library/Director/Objects/IcingaTimePeriod.php @@ -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); + } }