mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-07-27 07:44:05 +02:00
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 $supportsArguments = true;
|
||||||
|
|
||||||
|
protected static $pluginDir;
|
||||||
|
|
||||||
protected function renderMethods_execute()
|
protected function renderMethods_execute()
|
||||||
{
|
{
|
||||||
// Execute is a reserved word in SQL, column name was prefixed
|
// Execute is a reserved word in SQL, column name was prefixed
|
||||||
return c::renderKeyValue('execute', $this->methods_execute);
|
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()
|
protected function renderCommand()
|
||||||
{
|
{
|
||||||
$command = $this->command;
|
$command = $this->command;
|
||||||
@ -59,4 +80,9 @@ class IcingaCommand extends IcingaObject
|
|||||||
}
|
}
|
||||||
return c::renderKeyValue('timeout', $value);
|
return c::renderKeyValue('timeout', $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function setPluginDir($pluginDir)
|
||||||
|
{
|
||||||
|
self::$pluginDir = $pluginDir;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user