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
|
class PropertyModifierLowercase extends PropertyModifierHook
|
||||||
{
|
{
|
||||||
|
|
||||||
public function transform($value)
|
public function transform($value)
|
||||||
{
|
{
|
||||||
return strtolower($value);
|
return strtolower($value);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,28 +3,25 @@
|
||||||
namespace Icinga\Module\Director\PropertyModifier;
|
namespace Icinga\Module\Director\PropertyModifier;
|
||||||
|
|
||||||
use Icinga\Module\Director\Hook\PropertyModifierHook;
|
use Icinga\Module\Director\Hook\PropertyModifierHook;
|
||||||
|
use Icinga\Module\Director\Web\Form\QuickForm;
|
||||||
|
|
||||||
class PropertyModifierRegexReplace extends PropertyModifierHook
|
class PropertyModifierRegexReplace extends PropertyModifierHook
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
public static function addSettingsFormFields(QuickForm $form)
|
public static function addSettingsFormFields(QuickForm $form)
|
||||||
{
|
{
|
||||||
$form->addElement('text', 'pattern', array(
|
$form->addElement('text', 'pattern', array(
|
||||||
'label' => 'Regex pattern',
|
'label' => 'Regex pattern',
|
||||||
'required' => true,
|
'required' => true,
|
||||||
));
|
));
|
||||||
|
|
||||||
$form->addElement('text', 'replacement', array(
|
$form->addElement('text', 'replacement', array(
|
||||||
'label' => 'Replacement',
|
'label' => 'Replacement',
|
||||||
'required' => true,
|
'required' => true,
|
||||||
));
|
));
|
||||||
return $form;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function transform($value)
|
public function transform($value)
|
||||||
{
|
{
|
||||||
return preg_replace($this->settings['pattern'], $this->settings['replacement'], $value);
|
return preg_replace($this->settings['pattern'], $this->settings['replacement'], $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,26 +3,25 @@
|
||||||
namespace Icinga\Module\Director\PropertyModifier;
|
namespace Icinga\Module\Director\PropertyModifier;
|
||||||
|
|
||||||
use Icinga\Module\Director\Hook\PropertyModifierHook;
|
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)
|
public static function addSettingsFormFields(QuickForm $form)
|
||||||
{
|
{
|
||||||
$form->addElement('text', 'string', array(
|
$form->addElement('text', 'string', array(
|
||||||
'label' => 'Search string',
|
'label' => 'Search string',
|
||||||
'required' => true,
|
'required' => true,
|
||||||
));
|
));
|
||||||
|
|
||||||
$form->addElement('text', 'replacement', array(
|
$form->addElement('text', 'replacement', array(
|
||||||
'label' => 'Replacement',
|
'label' => 'Replacement',
|
||||||
'required' => true,
|
'required' => true,
|
||||||
));
|
));
|
||||||
return $form;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function transform($value)
|
public function transform($value)
|
||||||
{
|
{
|
||||||
return str_replace($this->settings['string'], $this->settings['replacement'], $value);
|
return str_replace($this->settings['string'], $this->settings['replacement'], $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,23 +3,21 @@
|
||||||
namespace Icinga\Module\Director\PropertyModifier;
|
namespace Icinga\Module\Director\PropertyModifier;
|
||||||
|
|
||||||
use Icinga\Module\Director\Hook\PropertyModifierHook;
|
use Icinga\Module\Director\Hook\PropertyModifierHook;
|
||||||
|
use Icinga\Module\Director\Web\Form\QuickForm;
|
||||||
|
|
||||||
class PropertyModifierStripDomain extends PropertyModifierHook
|
class PropertyModifierStripDomain extends PropertyModifierHook
|
||||||
{
|
{
|
||||||
|
|
||||||
public static function addSettingsFormFields(QuickForm $form)
|
public static function addSettingsFormFields(QuickForm $form)
|
||||||
{
|
{
|
||||||
$form->addElement('text', 'domain', array(
|
$form->addElement('text', 'domain', array(
|
||||||
'label' => 'Domain name',
|
'label' => 'Domain name',
|
||||||
'description' => 'Domain to be replaced',
|
'description' => 'Domain to be replaced',
|
||||||
'required' => true,
|
'required' => true,
|
||||||
));
|
));
|
||||||
return $form;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function transform($value)
|
public function transform($value)
|
||||||
{
|
{
|
||||||
return preg_replace($this->settings['domain'], "", $value);
|
return preg_replace($this->settings['domain'], "", $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,26 +3,25 @@
|
||||||
namespace Icinga\Module\Director\PropertyModifier;
|
namespace Icinga\Module\Director\PropertyModifier;
|
||||||
|
|
||||||
use Icinga\Module\Director\Hook\PropertyModifierHook;
|
use Icinga\Module\Director\Hook\PropertyModifierHook;
|
||||||
|
use Icinga\Module\Director\Web\Form\QuickForm;
|
||||||
|
|
||||||
class PropertyModifierSubstring extends PropertyModifierHook
|
class PropertyModifierSubstring extends PropertyModifierHook
|
||||||
{
|
{
|
||||||
|
|
||||||
public static function addSettingsFormFields(QuickForm $form)
|
public static function addSettingsFormFields(QuickForm $form)
|
||||||
{
|
{
|
||||||
$form->addElement('text', 'pattern', array(
|
$form->addElement('text', 'pattern', array(
|
||||||
'label' => 'Regex pattern',
|
'label' => 'Regex pattern',
|
||||||
'required' => true,
|
'required' => true,
|
||||||
));
|
));
|
||||||
|
|
||||||
$form->addElement('text', 'replacement', array(
|
$form->addElement('text', 'replacement', array(
|
||||||
'label' => 'Replacement',
|
'label' => 'Replacement',
|
||||||
'required' => true,
|
'required' => true,
|
||||||
));
|
));
|
||||||
return $form;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function transform($value)
|
public function transform($value)
|
||||||
{
|
{
|
||||||
return substr($value, $this->settings['start'], $this->settings['end'] - $this->settings['start']);
|
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
|
class PropertyModifierUppercase extends PropertyModifierHook
|
||||||
{
|
{
|
||||||
|
|
||||||
public function transform($value)
|
public function transform($value)
|
||||||
{
|
{
|
||||||
return strtoupper($value);
|
return strtoupper($value);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue