Director/PropertyModifier: Create first basic property modifiers refs: #9707

This commit is contained in:
Stefan Scheungrab 2015-07-23 14:29:15 +02:00
parent 103623211b
commit 06fc7d82a0
6 changed files with 76 additions and 1 deletions

View File

@ -1,6 +1,6 @@
<?php
namespace Icinga\Module\Director\Sync;
namespace Icinga\Module\Director\PropertyModifier;
use Icinga\Module\Director\Web\Hook\PropertyModifierHook;

View File

@ -0,0 +1,15 @@
<?php
namespace Icinga\Module\Director\PropertyModifier;
use Icinga\Module\Director\Web\Hook\PropertyModifierHook;
class PropertyModifierRegexReplace extends PropertyModifierHook
{
public function transform($value)
{
return preg_replace($this->settings['pattern'], $this->settings['replacement'], $value);
}
}

View File

@ -0,0 +1,15 @@
<?php
namespace Icinga\Module\Director\PropertyModifier;
use Icinga\Module\Director\Web\Hook\PropertyModifierHook;
class PropertyModifierReplace PropertyModifierHook
{
public function transform($value)
{
return str_replace($this->settings['string'], $this->settings['replacement'], $value);
}
}

View File

@ -0,0 +1,15 @@
<?php
namespace Icinga\Module\Director\PropertyModifier;
use Icinga\Module\Director\Web\Hook\PropertyModifierHook;
class PropertyModifierStripDomain extends PropertyModifierHook
{
public function transform($value)
{
return preg_replace($this->settings['domain'], "", $value);
}
}

View File

@ -0,0 +1,15 @@
<?php
namespace Icinga\Module\Director\PropertyModifier;
use Icinga\Module\Director\Web\Hook\PropertyModifierHook;
class PropertyModifierSubstring extends PropertyModifierHook
{
public function transform($value)
{
return substr($value, $this->settings['start'], $this->settings['end'] - $this->settings['start']);
}
}

View File

@ -0,0 +1,15 @@
<?php
namespace Icinga\Module\Director\PropertyModifier;
use Icinga\Module\Director\Web\Hook\PropertyModifierHook;
class PropertyModifierUppercase extends PropertyModifierHook
{
public function transform($value)
{
return strtoupper($value);
}
}