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:
mcq8
2017-12-10 21:20:28 +01:00
committed by Neil Lathwood
parent cfa3350cf2
commit 5ff03d5942
49 changed files with 1656 additions and 1368 deletions

View File

@@ -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';
}