Globalize getColorForState function (#10944)

* globalize getColorForState function
This commit is contained in:
SourceDoctor
2019-12-17 22:27:08 +01:00
committed by PipoCanaja
parent ae7eee438f
commit f835198a45
6 changed files with 26 additions and 28 deletions

View File

@@ -20,14 +20,14 @@ class Msteams extends Transport
if (!empty($this->config)) {
$opts['url'] = $this->config['msteam-url'];
}
return $this->contactMsteams($obj, $opts);
}
public function contactMsteams($obj, $opts)
{
$url = $opts['url'];
$data = array(
'title' => $obj['title'],
'themeColor' => self::getColorForState($obj['state']),
@@ -51,24 +51,6 @@ class Msteams extends Transport
}
return true;
}
/**
* Get the hex color string for a particular state
* @param integer $state State code from alert
* @return string Hex color, default to #337AB7 blue if state unrecognised
*/
public static function getColorForState($state)
{
$colors = array(
0 => '#00FF00', // OK - green
1 => '#FF0000', // Bad - red
2 => '#337AB7', // Acknowledged - blue
3 => '#FF0000', // Worse - red
4 => '#F0AD4E', // Better - yellow
);
return isset($colors[$state]) ? $colors[$state] : '#337AB7';
}
public static function configTemplate()
{