diff --git a/library/Director/PropertyModifier/PropertyModifierLConfCustomVar.php b/library/Director/PropertyModifier/PropertyModifierLConfCustomVar.php new file mode 100644 index 00000000..827b8e20 --- /dev/null +++ b/library/Director/PropertyModifier/PropertyModifierLConfCustomVar.php @@ -0,0 +1,43 @@ +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; + } +} diff --git a/run.php b/run.php index ad436e69..33ead0ea 100644 --- a/run.php +++ b/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');