parent
e6e51dc2be
commit
a7ff250ecd
|
@ -0,0 +1,43 @@
|
|||
<?php
|
||||
|
||||
namespace Icinga\Module\Director\PropertyModifier;
|
||||
|
||||
use Icinga\Module\Director\Hook\PropertyModifierHook;
|
||||
|
||||
class PropertyModifierLConfCustomVar extends PropertyModifierHook
|
||||
{
|
||||
public function transform($value)
|
||||
{
|
||||
if ($value === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$vars = (object) array();
|
||||
$this->extractLConfVars($value, $vars);
|
||||
|
||||
return $vars;
|
||||
}
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return 'Transform LConf CustomVars to Hash';
|
||||
}
|
||||
|
||||
protected function extractLConfVars($value, $vars)
|
||||
{
|
||||
if (is_string($value)) {
|
||||
$this->extractLConfVar($value, $vars);
|
||||
} elseif (is_array($value)) {
|
||||
foreach ($value as $val) {
|
||||
$this->extractLConfVar($val, $vars);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected function extractLConfVar($value, $vars)
|
||||
{
|
||||
list($key, $val) = preg_split('/ /', $value, 2);
|
||||
$key = rtrim($key, '_');
|
||||
$vars->$key = $val;
|
||||
}
|
||||
}
|
1
run.php
1
run.php
|
@ -38,6 +38,7 @@ $this->provideHook('director/PropertyModifier', $prefix . 'PropertyModifier\\Pro
|
|||
$this->provideHook('director/PropertyModifier', $prefix . 'PropertyModifier\\PropertyModifierMakeBoolean');
|
||||
$this->provideHook('director/PropertyModifier', $prefix . 'PropertyModifier\\PropertyModifierJsonDecode');
|
||||
$this->provideHook('director/PropertyModifier', $prefix . 'PropertyModifier\\PropertyModifierToInt');
|
||||
$this->provideHook('director/PropertyModifier', $prefix . 'PropertyModifier\\PropertyModifierLConfCustomVar');
|
||||
|
||||
$this->provideHook('director/Job', $prefix . 'Job\\HousekeepingJob');
|
||||
$this->provideHook('director/Job', $prefix . 'Job\\ConfigJob');
|
||||
|
|
Loading…
Reference in New Issue