2015-07-23 14:29:15 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Icinga\Module\Director\PropertyModifier;
|
|
|
|
|
|
|
|
use Icinga\Module\Director\Web\Hook\PropertyModifierHook;
|
|
|
|
|
|
|
|
class PropertyModifierRegexReplace extends PropertyModifierHook
|
|
|
|
{
|
|
|
|
|
2015-07-23 14:42:53 +02:00
|
|
|
|
|
|
|
public static function addSettingsFormFields(QuickForm $form)
|
|
|
|
{
|
2015-07-23 15:13:07 +02:00
|
|
|
$form->addElement('text', 'pattern', array(
|
|
|
|
'label' => 'Regex pattern',
|
2015-07-23 14:42:53 +02:00
|
|
|
'required' => true,
|
|
|
|
));
|
2015-07-23 15:13:07 +02:00
|
|
|
$form->addElement('text', 'replacement', array(
|
|
|
|
'label' => 'Replacement',
|
2015-07-23 14:42:53 +02:00
|
|
|
'required' => true,
|
|
|
|
));
|
|
|
|
return $form;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-07-23 14:29:15 +02:00
|
|
|
public function transform($value)
|
|
|
|
{
|
|
|
|
return preg_replace($this->settings['pattern'], $this->settings['replacement'], $value);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|