monitoring/commands: Do not require command objects to return the command string

There will be command renderer instead.

refs #6593
This commit is contained in:
Eric Lippmann 2014-09-09 16:35:06 +02:00
parent 0e7ca591ec
commit a841b0956d

View File

@ -10,35 +10,12 @@ namespace Icinga\Module\Monitoring\Command;
abstract class IcingaCommand abstract class IcingaCommand
{ {
/** /**
* Get the command string * Get the name of the command
* *
* @return string * @return string
*/ */
abstract public function getCommandString(); public function getName()
/**
* Escape a command string
*
* @param string $commandString
*
* @return string
*/
public function escape($commandString)
{ {
return str_replace(array("\r", "\n"), array('\r', '\n'), $commandString); return substr_replace(end(explode('\\', get_called_class())), '', -7); // Remove 'Command' Suffix
}
/**
* Get the command as string with the current timestamp as the command submission time
*
* @return string
*/
public function __toString()
{
return sprintf(
'[%u] %s',
time(),
$this->escape($this->getCommandString())
);
} }
} }