IcingaCommand: add mungeCommand
Supports arrays and optional PluginDir resolution
This commit is contained in:
parent
502e139516
commit
e29da23f99
|
@ -28,12 +28,33 @@ class IcingaCommand extends IcingaObject
|
|||
|
||||
protected $supportsArguments = true;
|
||||
|
||||
protected static $pluginDir;
|
||||
|
||||
protected function renderMethods_execute()
|
||||
{
|
||||
// Execute is a reserved word in SQL, column name was prefixed
|
||||
return c::renderKeyValue('execute', $this->methods_execute);
|
||||
}
|
||||
|
||||
public function mungeCommand($value)
|
||||
{
|
||||
if (is_array($value)) {
|
||||
$value = implode(' ', $value);
|
||||
} elseif (is_object($value)) {
|
||||
// { type => Function } -> really??
|
||||
return null;
|
||||
return $value;
|
||||
}
|
||||
|
||||
if (self::$pluginDir !== null) {
|
||||
if (($pos = strpos($value, self::$pluginDir)) === 0) {
|
||||
$value = substr($value, strlen(self::$pluginDir) + 1);
|
||||
}
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
protected function renderCommand()
|
||||
{
|
||||
$command = $this->command;
|
||||
|
@ -59,4 +80,9 @@ class IcingaCommand extends IcingaObject
|
|||
}
|
||||
return c::renderKeyValue('timeout', $value);
|
||||
}
|
||||
|
||||
public static function setPluginDir($pluginDir)
|
||||
{
|
||||
self::$pluginDir = $pluginDir;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue