2015-07-23 14:29:15 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Icinga\Module\Director\PropertyModifier;
|
|
|
|
|
2016-02-17 11:11:05 +01:00
|
|
|
use Icinga\Module\Director\Hook\PropertyModifierHook;
|
2016-02-18 23:21:28 +01:00
|
|
|
use Icinga\Module\Director\Web\Form\QuickForm;
|
2015-07-23 14:29:15 +02:00
|
|
|
|
2016-02-18 23:21:28 +01:00
|
|
|
class PropertyModifierReplace extends PropertyModifierHook
|
2015-07-23 14:29:15 +02:00
|
|
|
{
|
2015-07-23 14:42:53 +02:00
|
|
|
public static function addSettingsFormFields(QuickForm $form)
|
|
|
|
{
|
|
|
|
$form->addElement('text', 'string', array(
|
2016-03-06 00:37:03 +01:00
|
|
|
'label' => 'Search string',
|
|
|
|
'description' => $form->translate('The string you want to search for'),
|
|
|
|
'required' => true,
|
2015-07-23 14:42:53 +02:00
|
|
|
));
|
2016-02-18 23:21:28 +01:00
|
|
|
|
2015-07-23 14:42:53 +02:00
|
|
|
$form->addElement('text', 'replacement', array(
|
2016-03-06 00:37:03 +01:00
|
|
|
'label' => 'Replacement',
|
|
|
|
'description' => $form->translate('Your replacement string'),
|
|
|
|
'required' => true,
|
2015-07-23 14:42:53 +02:00
|
|
|
));
|
|
|
|
}
|
|
|
|
|
2015-07-23 14:29:15 +02:00
|
|
|
public function transform($value)
|
|
|
|
{
|
|
|
|
return str_replace($this->settings['string'], $this->settings['replacement'], $value);
|
|
|
|
}
|
|
|
|
}
|