Thomas Gelf f91dd5fa0e PropertyModifierCombine: implementation, tests...
...and related changes with some documentation

fixes #922
2017-05-03 10:39:49 +02:00

41 lines
1.2 KiB
PHP

<?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 idendifiers 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());
}
}