mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-27 07:44:04 +02:00
monitoring: Rewrite Service::getStateText() to get the optional translated textual representation of a service state
This commit is contained in:
parent
5fc1f85b76
commit
d9194c2696
@ -199,34 +199,35 @@ class Service extends MonitoredObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the translated textual representation of a service state
|
* Get the optional translated textual representation of a service state
|
||||||
*
|
*
|
||||||
* @param int $state
|
* @param int $state
|
||||||
|
* @param bool $translate
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
* @throws InvalidArgumentException If the service state is not valid
|
* @throws InvalidArgumentException If the service state is not valid
|
||||||
*/
|
*/
|
||||||
public static function getStateText($state)
|
public static function getStateText($state, $translate = false)
|
||||||
{
|
{
|
||||||
|
$translate = (bool) $translate;
|
||||||
switch ((int) $state) {
|
switch ((int) $state) {
|
||||||
case self::STATE_OK:
|
case self::STATE_OK:
|
||||||
$text = mt('monitoring', 'ok');
|
$text = $translate ? mt('monitoring', 'ok') : 'ok';
|
||||||
break;
|
break;
|
||||||
case self::STATE_WARNING:
|
case self::STATE_WARNING:
|
||||||
$text = mt('monitoring', 'warning');
|
$text = $translate ? mt('monitoring', 'warning') : 'warning';
|
||||||
break;
|
break;
|
||||||
case self::STATE_CRITICAL:
|
case self::STATE_CRITICAL:
|
||||||
$text = mt('monitoring', 'critical');
|
$text = $translate ? mt('monitoring', 'critical') : 'critical';
|
||||||
break;
|
break;
|
||||||
case self::STATE_UNKNOWN:
|
case self::STATE_UNKNOWN:
|
||||||
$text = mt('monitoring', 'unknown');
|
$text = $translate ? mt('monitoring', 'unknown') : 'unknown';
|
||||||
break;
|
break;
|
||||||
case self::STATE_PENDING:
|
case self::STATE_PENDING:
|
||||||
$text = mt('monitoring', 'pending');
|
$text = $translate ? mt('monitoring', 'pending') : 'pending';
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new InvalidArgumentException('Invalid service state \'%s\'', $state);
|
throw new InvalidArgumentException('Invalid service state \'%s\'', $state);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
return $text;
|
return $text;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user