summaryrefslogtreecommitdiffstats
path: root/library/Director/PropertyModifier/PropertyModifierMap.php
diff options
context:
space:
mode:
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(