-
Notifications
You must be signed in to change notification settings - Fork 203
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PropertyModifier: Replace Null with String
- Loading branch information
1 parent
67eb4c1
commit 4692b28
Showing
2 changed files
with
35 additions
and
0 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
library/Director/PropertyModifier/PropertyModifierReplaceNull.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
namespace Icinga\Module\Director\PropertyModifier; | ||
|
||
use Icinga\Module\Director\Hook\PropertyModifierHook; | ||
use Icinga\Module\Director\Web\Form\QuickForm; | ||
|
||
class PropertyModifierReplaceNull extends PropertyModifierHook | ||
{ | ||
|
||
public function getName() | ||
{ | ||
return 'Replace null value with String'; | ||
} | ||
|
||
public static function addSettingsFormFields(QuickForm $form) | ||
{ | ||
$form->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; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters