diff options
Diffstat (limited to 'library/Director/PropertyModifier/PropertyModifierCombine.php')
-rw-r--r-- | library/Director/PropertyModifier/PropertyModifierCombine.php | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/library/Director/PropertyModifier/PropertyModifierCombine.php b/library/Director/PropertyModifier/PropertyModifierCombine.php new file mode 100644 index 0000000..5be09ea --- /dev/null +++ b/library/Director/PropertyModifier/PropertyModifierCombine.php @@ -0,0 +1,40 @@ +<?php + +namespace Icinga\Module\Director\PropertyModifier; + +use Icinga\Module\Director\Hook\PropertyModifierHook; +use Icinga\Module\Director\Import\SyncUtils; +use Icinga\Module\Director\Web\Form\QuickForm; + +class PropertyModifierCombine extends PropertyModifierHook +{ + public static function addSettingsFormFields(QuickForm $form) + { + $form->addElement('text', 'pattern', array( + 'label' => $form->translate('Pattern'), + 'required' => false, + 'description' => $form->translate( + 'This pattern 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.' + ) + )); + } + + public function getName() + { + return 'Combine multiple properties'; + } + + public function requiresRow() + { + return true; + } + + public function transform($value) + { + return SyncUtils::fillVariables($this->getSetting('pattern'), $this->getRow()); + } +} |