mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-23 05:44:36 +02:00
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:
parent
0e7ca591ec
commit
a841b0956d
@ -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())
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user