diff --git a/library/Director/PropertyModifier/PropertyModifierReplaceNull.php b/library/Director/PropertyModifier/PropertyModifierReplaceNull.php new file mode 100644 index 000000000..f59f5b834 --- /dev/null +++ b/library/Director/PropertyModifier/PropertyModifierReplaceNull.php @@ -0,0 +1,33 @@ +addElement('text', 'string', array( + 'label' => 'Replacement String', + 'description' => $form->translate('Your replacement string'), + 'required' => true, + )); + } + + public function transform($value) + { + if ($value === null) { + return $this->getSetting('string'); + } else { + return $value; + } + } +} diff --git a/register-hooks.php b/register-hooks.php index a37aa706e..d628e4e34 100644 --- a/register-hooks.php +++ b/register-hooks.php @@ -45,6 +45,7 @@ use Icinga\Module\Director\PropertyModifier\PropertyModifierRejectOrSelect; use Icinga\Module\Director\PropertyModifier\PropertyModifierRenameColumn; use Icinga\Module\Director\PropertyModifier\PropertyModifierReplace; +use Icinga\Module\Director\PropertyModifier\PropertyModifierReplaceNull; use Icinga\Module\Director\PropertyModifier\PropertyModifierSimpleGroupBy; use Icinga\Module\Director\PropertyModifier\PropertyModifierSkipDuplicates; use Icinga\Module\Director\PropertyModifier\PropertyModifierSplit; @@ -118,6 +119,7 @@ PropertyModifierRejectOrSelect::class, PropertyModifierRenameColumn::class, PropertyModifierReplace::class, + PropertyModifierReplaceNull::class, PropertyModifierSimpleGroupBy::class, PropertyModifierSkipDuplicates::class, PropertyModifierSplit::class,