PropertyModifiers: fix errors, style, logic
This commit is contained in:
parent
81335598a6
commit
d34a7dd5aa
|
@ -6,10 +6,8 @@ use Icinga\Module\Director\Hook\PropertyModifierHook;
|
|||
|
||||
class PropertyModifierLowercase extends PropertyModifierHook
|
||||
{
|
||||
|
||||
public function transform($value)
|
||||
{
|
||||
return strtolower($value);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -3,28 +3,25 @@
|
|||
namespace Icinga\Module\Director\PropertyModifier;
|
||||
|
||||
use Icinga\Module\Director\Hook\PropertyModifierHook;
|
||||
use Icinga\Module\Director\Web\Form\QuickForm;
|
||||
|
||||
class PropertyModifierRegexReplace extends PropertyModifierHook
|
||||
{
|
||||
|
||||
|
||||
public static function addSettingsFormFields(QuickForm $form)
|
||||
{
|
||||
$form->addElement('text', 'pattern', array(
|
||||
'label' => 'Regex pattern',
|
||||
'required' => true,
|
||||
));
|
||||
|
||||
$form->addElement('text', 'replacement', array(
|
||||
'label' => 'Replacement',
|
||||
'required' => true,
|
||||
));
|
||||
return $form;
|
||||
}
|
||||
|
||||
|
||||
public function transform($value)
|
||||
{
|
||||
return preg_replace($this->settings['pattern'], $this->settings['replacement'], $value);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -3,26 +3,25 @@
|
|||
namespace Icinga\Module\Director\PropertyModifier;
|
||||
|
||||
use Icinga\Module\Director\Hook\PropertyModifierHook;
|
||||
use Icinga\Module\Director\Web\Form\QuickForm;
|
||||
|
||||
class PropertyModifierReplace PropertyModifierHook
|
||||
class PropertyModifierReplace extends PropertyModifierHook
|
||||
{
|
||||
|
||||
public static function addSettingsFormFields(QuickForm $form)
|
||||
{
|
||||
$form->addElement('text', 'string', array(
|
||||
'label' => 'Search string',
|
||||
'required' => true,
|
||||
));
|
||||
|
||||
$form->addElement('text', 'replacement', array(
|
||||
'label' => 'Replacement',
|
||||
'required' => true,
|
||||
));
|
||||
return $form;
|
||||
}
|
||||
|
||||
public function transform($value)
|
||||
{
|
||||
return str_replace($this->settings['string'], $this->settings['replacement'], $value);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -3,23 +3,21 @@
|
|||
namespace Icinga\Module\Director\PropertyModifier;
|
||||
|
||||
use Icinga\Module\Director\Hook\PropertyModifierHook;
|
||||
use Icinga\Module\Director\Web\Form\QuickForm;
|
||||
|
||||
class PropertyModifierStripDomain extends PropertyModifierHook
|
||||
{
|
||||
|
||||
public static function addSettingsFormFields(QuickForm $form)
|
||||
{
|
||||
$form->addElement('text', 'domain', array(
|
||||
'label' => 'Domain name',
|
||||
'description' => 'Domain to be replaced',
|
||||
'description' => 'Domain to be replaced',
|
||||
'required' => true,
|
||||
));
|
||||
return $form;
|
||||
}
|
||||
|
||||
public function transform($value)
|
||||
{
|
||||
return preg_replace($this->settings['domain'], "", $value);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -3,26 +3,25 @@
|
|||
namespace Icinga\Module\Director\PropertyModifier;
|
||||
|
||||
use Icinga\Module\Director\Hook\PropertyModifierHook;
|
||||
use Icinga\Module\Director\Web\Form\QuickForm;
|
||||
|
||||
class PropertyModifierSubstring extends PropertyModifierHook
|
||||
{
|
||||
|
||||
public static function addSettingsFormFields(QuickForm $form)
|
||||
{
|
||||
$form->addElement('text', 'pattern', array(
|
||||
'label' => 'Regex pattern',
|
||||
'required' => true,
|
||||
));
|
||||
|
||||
$form->addElement('text', 'replacement', array(
|
||||
'label' => 'Replacement',
|
||||
'required' => true,
|
||||
));
|
||||
return $form;
|
||||
}
|
||||
|
||||
public function transform($value)
|
||||
{
|
||||
return substr($value, $this->settings['start'], $this->settings['end'] - $this->settings['start']);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -6,10 +6,8 @@ use Icinga\Module\Director\Hook\PropertyModifierHook;
|
|||
|
||||
class PropertyModifierUppercase extends PropertyModifierHook
|
||||
{
|
||||
|
||||
public function transform($value)
|
||||
{
|
||||
return strtoupper($value);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue