PropertyModifier: renamed function for adding new fields to a Form

This commit is contained in:
Stefan Scheungrab 2015-07-23 14:42:53 +02:00
parent 06fc7d82a0
commit b43b8ee5e3
5 changed files with 52 additions and 1 deletions

View File

@ -7,6 +7,21 @@ use Icinga\Module\Director\Web\Hook\PropertyModifierHook;
class PropertyModifierRegexReplace extends PropertyModifierHook
{
public static function addSettingsFormFields(QuickForm $form)
{
$form->addElement('text', 'start', array(
'label' => 'Start index',
'required' => true,
));
$form->addElement('text', 'start', array(
'label' => 'End index',
'required' => true,
));
return $form;
}
public function transform($value)
{
return preg_replace($this->settings['pattern'], $this->settings['replacement'], $value);

View File

@ -7,6 +7,19 @@ use Icinga\Module\Director\Web\Hook\PropertyModifierHook;
class PropertyModifierReplace 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);

View File

@ -7,6 +7,16 @@ use Icinga\Module\Director\Web\Hook\PropertyModifierHook;
class PropertyModifierStripDomain extends PropertyModifierHook
{
public static function addSettingsFormFields(QuickForm $form)
{
$form->addElement('text', 'domain', array(
'label' => 'Domain name',
'description' => 'Domain to be replaced',
'required' => true,
));
return $form;
}
public function transform($value)
{
return preg_replace($this->settings['domain'], "", $value);

View File

@ -7,6 +7,19 @@ use Icinga\Module\Director\Web\Hook\PropertyModifierHook;
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']);

View File

@ -81,7 +81,7 @@ abstract class PropertyModifierHook
* @param QuickForm $form QuickForm that should be extended
* @return QuickForm
*/
public static function addPropertiesFormFields(QuickForm $form)
public static function addSettingsFormFields(QuickForm $form)
{
return $form;
}