From 3a4db5194ce3735029651debac381a2f02f1ab4f Mon Sep 17 00:00:00 2001 From: Guillaume COEUGNET Date: Wed, 30 Mar 2016 16:01:16 +0200 Subject: [PATCH] Remove namespaces to allow this transport to be called from anonymous function --- includes/alerts/transport.canopsis.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/includes/alerts/transport.canopsis.php b/includes/alerts/transport.canopsis.php index f5c0b9d1d7..def4b095d8 100644 --- a/includes/alerts/transport.canopsis.php +++ b/includes/alerts/transport.canopsis.php @@ -1,6 +1,4 @@ -require_once "/usr/share/php/PhpAmqpLib/autoload.php"; -use PhpAmqpLib\Connection\AMQPConnection; -use PhpAmqpLib\Message\AMQPMessage; +require_once "./lib/PhpAmqpLib/autoload.php"; // Configurations $host = $opts["host"]; @@ -11,7 +9,7 @@ $vhost = $opts["vhost"]; $exchange = "canopsis.events"; // Connection -$conn = new AMQPConnection($host, $port, $user, $pass, $vhost); +$conn = new PhpAmqpLib\Connection\AMQPConnection($host, $port, $user, $pass, $vhost); $ch = $conn->channel(); // Declare exchange (if not exist) @@ -51,7 +49,7 @@ else $msg_rk = $msg_body['connector'].".".$msg_body['connector_name'].".".$msg_body['event_type'].".".$msg_body['source_type'].".".$msg_body['component']; // Publish Event -$msg = new AMQPMessage($msg_raw, array('content_type' => 'application/json', 'delivery_mode' => 2)); +$msg = new PhpAmqpLib\Message\AMQPMessage($msg_raw, array('content_type' => 'application/json', 'delivery_mode' => 2)); $ch->basic_publish($msg, $exchange, $msg_rk); // Close connection