From de0b3db8a27998f26fe5630ffbe54859d222f7e0 Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Thu, 4 Jul 2019 09:19:40 +0200 Subject: [PATCH] IcingaDependencyForm: allow to store var names --- application/forms/IcingaDependencyForm.php | 26 ++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/application/forms/IcingaDependencyForm.php b/application/forms/IcingaDependencyForm.php index 4a4a9ff5..7f1ff62e 100644 --- a/application/forms/IcingaDependencyForm.php +++ b/application/forms/IcingaDependencyForm.php @@ -2,6 +2,7 @@ namespace Icinga\Module\Director\Forms; +use Icinga\Module\Director\Data\Db\DbObject; use Icinga\Module\Director\Web\Form\DirectorObjectForm; use Icinga\Module\Director\Objects\IcingaDependency; @@ -287,4 +288,29 @@ class IcingaDependencyForm extends DirectorObjectForm return $this; } + + protected function handleProperties(DbObject $object, & $values) + { + if ($this->hasBeenSent()) { + if (isset($values['parent_host']) + && $this->isCustomVar($values['parent_host']) + ) { + $values['parent_host_var'] = $values['parent_host']; + $values['parent_host'] = ''; + } + if (isset($values['parent_service']) + && $this->isCustomVar($values['parent_service']) + ) { + $values['parent_service_var'] = $values['parent_service']; + $values['parent_service'] = ''; + } + } + + parent::handleProperties($object, $values); + } + + protected function isCustomVar($string) + { + return \preg_match('/^(?:host|service)\.vars\./', $string); + } }