PropertyModifier: RenameColumn

fixes #2242
This commit is contained in:
Thomas Gelf 2020-12-02 18:01:21 +01:00
parent c12cf5ddb3
commit ee2bae47f3
2 changed files with 36 additions and 0 deletions

View File

@ -0,0 +1,34 @@
<?php
namespace Icinga\Module\Director\PropertyModifier;
use Icinga\Module\Director\Hook\PropertyModifierHook;
class PropertyModifierRenameColumn extends PropertyModifierHook
{
public function getName()
{
return 'Rename a Property/Column';
}
public function requiresRow()
{
return true;
}
public function hasArraySupport()
{
return true;
}
public function transform($value)
{
$row = $this->getRow();
$property = $this->getPropertyName();
if ($row) {
unset($row->$property);
}
// $this->rejectRow();
return $value;
}
}

View File

@ -42,6 +42,7 @@ use Icinga\Module\Director\PropertyModifier\PropertyModifierParseURL;
use Icinga\Module\Director\PropertyModifier\PropertyModifierRegexReplace;
use Icinga\Module\Director\PropertyModifier\PropertyModifierRegexSplit;
use Icinga\Module\Director\PropertyModifier\PropertyModifierRejectOrSelect;
use Icinga\Module\Director\PropertyModifier\PropertyModifierRenameColumn;
use Icinga\Module\Director\PropertyModifier\PropertyModifierReplace;
use Icinga\Module\Director\PropertyModifier\PropertyModifierSkipDuplicates;
use Icinga\Module\Director\PropertyModifier\PropertyModifierSplit;
@ -110,6 +111,7 @@ $directorHooks = [
PropertyModifierRegexReplace::class,
PropertyModifierRegexSplit::class,
PropertyModifierRejectOrSelect::class,
PropertyModifierRenameColumn::class,
PropertyModifierReplace::class,
PropertyModifierSkipDuplicates::class,
PropertyModifierSplit::class,