diff --git a/library/Director/Objects/IcingaCommand.php b/library/Director/Objects/IcingaCommand.php index 74cbf0ea..dfa02691 100644 --- a/library/Director/Objects/IcingaCommand.php +++ b/library/Director/Objects/IcingaCommand.php @@ -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; + } }