summaryrefslogtreecommitdiffstats
path: root/library/Director/PropertyModifier/PropertyModifierMap.php
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-14 13:17:47 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-14 13:17:47 +0000
commit5419d4428c86c488a43124f85e5407d7cbae6541 (patch)
tree772c4221a20fd7d1b3e7e67c6e21755a50e80fd7 /library/Director/PropertyModifier/PropertyModifierMap.php
parentAdding upstream version 1.10.2. (diff)
downloadicingaweb2-module-director-upstream.tar.xz
icingaweb2-module-director-upstream.zip
Adding upstream version 1.11.1.upstream/1.11.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'library/Director/PropertyModifier/PropertyModifierMap.php')
-rw-r--r--library/Director/PropertyModifier/PropertyModifierMap.php32
1 files changed, 29 insertions, 3 deletions
diff --git a/library/Director/PropertyModifier/PropertyModifierMap.php b/library/Director/PropertyModifier/PropertyModifierMap.php
index a6cb422..e411c54 100644
--- a/library/Director/PropertyModifier/PropertyModifierMap.php
+++ b/library/Director/PropertyModifier/PropertyModifierMap.php
@@ -4,6 +4,7 @@ namespace Icinga\Module\Director\PropertyModifier;
use Icinga\Exception\InvalidPropertyException;
use Icinga\Module\Director\Hook\PropertyModifierHook;
+use Icinga\Module\Director\Import\SyncUtils;
use Icinga\Module\Director\Web\Form\QuickForm;
class PropertyModifierMap extends PropertyModifierHook
@@ -30,15 +31,37 @@ class PropertyModifierMap extends PropertyModifierHook
. ' or interrupt the import process'
),
'multiOptions' => $form->optionalEnum(array(
- 'null' => $form->translate('Set null'),
- 'keep' => $form->translate('Return lookup key unmodified'),
- 'fail' => $form->translate('Let the import fail'),
+ 'null' => $form->translate('Set null'),
+ 'keep' => $form->translate('Return lookup key unmodified'),
+ 'custom' => $form->translate('Return custom default value'),
+ 'fail' => $form->translate('Let the import fail'),
)),
+ 'class' => 'autosubmit',
));
+ $method = $form->getSetting('on_missing');
+ if ($method == 'custom') {
+ $form->addElement('text', 'custom_value', array(
+ 'label' => $form->translate('Default value'),
+ 'required' => true,
+ 'description' => $form->translate(
+ 'This value will be evaluated, and variables like ${some_column}'
+ . ' will be filled accordingly. A typical use-case is generating'
+ . ' unique service identifiers via ${host}!${service} in case your'
+ . ' data source doesn\'t allow you to ship such. The chosen "property"'
+ . ' has no effect here and will be ignored.'
+ )
+ ));
+ }
+
// TODO: ignore case
}
+ public function requiresRow()
+ {
+ return true;
+ }
+
public function transform($value)
{
$this->loadCache();
@@ -53,6 +76,9 @@ class PropertyModifierMap extends PropertyModifierHook
case 'keep':
return $value;
+ case 'custom':
+ return SyncUtils::fillVariables($this->getSetting('custom_value'), $this->getRow());
+
case 'fail':
default:
throw new InvalidPropertyException(