mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
refactor: Refactor alert transports to classes (#7844)
* Refactor alert transports to classes * Fix linting * Make Slack alert transport php 5.3 compatible * Rename call method to deliverAlert for alert transport
This commit is contained in:
@@ -46,11 +46,12 @@ $obj = array(
|
||||
|
||||
$status = 'error';
|
||||
|
||||
if (file_exists($config['install_dir']."/includes/alerts/transport.".$transport.".php")) {
|
||||
$class = 'LibreNMS\\Alert\\Transport\\' . ucfirst($transport);
|
||||
if (class_exists($class)) {
|
||||
$opts = $config['alert']['transports'][$transport];
|
||||
if ($opts) {
|
||||
eval('$tmp = function($obj,$opts) { global $config; '.file_get_contents($config['install_dir'].'/includes/alerts/transport.'.$transport.'.php').' return false; };');
|
||||
$tmp = $tmp($obj, $opts);
|
||||
$instance = new $class;
|
||||
$tmp = $instance->deliverAlert($obj, $opts);
|
||||
if ($tmp) {
|
||||
$status = 'ok';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user