IcingaCommand: extend input handling, be flexible
This commit is contained in:
parent
7832cf85f1
commit
a1aea38cb4
|
@ -36,6 +36,17 @@ class IcingaCommand extends IcingaObject
|
||||||
|
|
||||||
protected function renderCommand()
|
protected function renderCommand()
|
||||||
{
|
{
|
||||||
return c::renderKeyValue('command', c::renderArray(array($this->command)));
|
$command = $this->command;
|
||||||
|
$prefix = '';
|
||||||
|
if (preg_match('~^([A-Z][A-Za-z0-9]+\s\+\s)(.+?)$~', $command, $m)) {
|
||||||
|
$prefix = $m[1];
|
||||||
|
$command = $m[2];
|
||||||
|
} elseif ($command[0] !== '/') {
|
||||||
|
$prefix = 'PluginDir + ';
|
||||||
|
}
|
||||||
|
$parts = preg_split('/\s+/', $command, -1, PREG_SPLIT_NO_EMPTY);
|
||||||
|
array_unshift($parts, c::alreadyRendered($prefix . c::renderString(array_shift($parts))));
|
||||||
|
|
||||||
|
return c::renderKeyValue('command', c::renderArray($parts));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue