<?php
namespace Icinga\Module\Directorextension\PropertyModifier;
use Icinga\Module\Director\Hook\PropertyModifierHook;
use Icinga\Module\Director\Web\Form\QuickForm;
class PropertyModifierTestProperty extends PropertyModifierHook
{
public static function addSettingsFormFields(QuickForm $form)
{
$form->addElement('text', 'pattern', array(
'label' => 'Regex pattern',
'description' => $form->translate(
'The pattern you want to search for. This can be a regular expression like /^www\d+\./'
),
'required' => true,
));
$form->addElement('text', 'replacement', array(
'label' => 'Replacement',
'description' => $form->translate(
'The string that should be used as a preplacement'
),
));
}
public function getName()
{
return 'This is a test';
}
public function transform($value)
{
return preg_replace(
$this->getSetting('pattern'),
$this->getSetting('replacement'),
$value
);
}
}
At last, I created the run.php and the module.info file
Now I activated my module in icingaweb.
I thought now, that I’m able to see my new property in the Import Source Property Modifier list, but its missing.
The one thing I see is the Library/Director which has to be the name of your Module so Library/Directorextension. But I know no example for a module using this hook, so this is the only idea I have.
Change /usr/share/icingaweb2/modules/directorextension/library/Directorextension/ProvidedHook/Director/PropertyModifier/PropertyModifierTestProperty.php to contain: