blob: 54e66162339cf920c575922b8e42a5ff18be351f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
<?php
namespace Icinga\Module\Director\PropertyModifier;
use Icinga\Module\Director\Hook\PropertyModifierHook;
use Icinga\Module\Director\Web\Form\QuickForm;
class PropertyModifierReplace extends PropertyModifierHook
{
public static function addSettingsFormFields(QuickForm $form)
{
$form->addElement('text', 'string', array(
'label' => 'Search string',
'description' => $form->translate('The string you want to search for'),
'required' => true,
));
$form->addElement('text', 'replacement', array(
'label' => 'Replacement',
'description' => $form->translate('Your replacement string'),
));
}
public function transform($value)
{
if ($value === null) {
return null;
}
return str_replace(
$this->getSetting('string'),
$this->getSetting('replacement'),
$value
);
}
}
|