PropertyModifierToInt: new property modifier

This commit is contained in:
Thomas Gelf 2016-09-14 19:35:51 +00:00
parent 407a387dab
commit a17fc32b41
2 changed files with 25 additions and 0 deletions

View File

@ -0,0 +1,24 @@
<?php
namespace Icinga\Module\Director\PropertyModifier;
use Icinga\Module\Director\Hook\PropertyModifierHook;
class PropertyModifierToInt extends PropertyModifierHook
{
public function getName()
{
return 'Cast a string value to an Integer';
}
public function transform($value)
{
if (is_int($value)) {
return $value;
}
if (is_string($value)) {
return (int) $value;
}
}
}

View File

@ -34,6 +34,7 @@ $this->provideHook('director/PropertyModifier', $prefix . 'PropertyModifier\\Pro
$this->provideHook('director/PropertyModifier', $prefix . 'PropertyModifier\\PropertyModifierBitmask');
$this->provideHook('director/PropertyModifier', $prefix . 'PropertyModifier\\PropertyModifierMakeBoolean');
$this->provideHook('director/PropertyModifier', $prefix . 'PropertyModifier\\PropertyModifierJsonDecode');
$this->provideHook('director/PropertyModifier', $prefix . 'PropertyModifier\\PropertyModifierToInt');
$this->provideHook('director/Job', $prefix . 'Job\\HousekeepingJob');
$this->provideHook('director/Job', $prefix . 'Job\\ConfigJob');