Page MenuHomeDevCentral

D809.diff
No OneTemporary

D809.diff

diff --git a/app/Listeners/AMQPEventListener.php b/app/Listeners/AMQPEventListener.php
--- a/app/Listeners/AMQPEventListener.php
+++ b/app/Listeners/AMQPEventListener.php
@@ -6,6 +6,8 @@
use Nasqueron\Notifications\Jobs\SendMessageToBroker;
use Nasqueron\Notifications\Notifications\Notification;
+use Illuminate\Events\Dispatcher;
+
use Config;
class AMQPEventListener {
@@ -20,7 +22,7 @@
* @param NotificationEvent $event
*/
public function onNotification(NotificationEvent $event) : void {
- $this->sendNotification($event);
+ $this->sendNotification($event->notification);
}
/**
@@ -29,24 +31,22 @@
* @param NotificationEvent $event
*/
protected static function getNotificationRoutingKey (Notification $notification) : string {
- $key = [
+ $keyParts = [
$notification->project,
$notification->group,
$notification->service,
- $notification->type
+ $notification->type,
];
- return strtolower(implode('.', $key));
+ return strtolower(implode('.', $keyParts));
}
/**
- * This is our gateway specialized for distilled notifications
+ * Sends the notification to the broker target for distilled notifications.
*
- * @param NotificationEvent $event
+ * @param Notification The notification to send
*/
- protected function sendNotification(NotificationEvent $event) : void {
- $notification = $event->notification;
-
+ protected function sendNotification(Notification $notification) : void {
$target = Config::get('broker.targets.notifications');
$routingKey = static::getNotificationRoutingKey($notification);
$message = json_encode($notification);
@@ -60,15 +60,13 @@
///
/**
- * Register the listeners for the subscriber.
+ * Registers the listeners for the subscriber.
*
- * @param \Illuminate\Events\Dispatcher $events
+ * @param Dispatcher $events
*/
- public function subscribe (\Illuminate\Events\Dispatcher $events) : void {
- $class = 'Nasqueron\Notifications\Listeners\AMQPEventListener';
- $events->listen(
- 'Nasqueron\Notifications\Events\NotificationEvent',
- "$class@onNotification"
- );
+ public function subscribe (Dispatcher $events) : void {
+ $class = AMQPEventListener::class;
+ $events->listen(NotificationEvent::class, "$class@onNotification");
}
+
}

File Metadata

Mime Type
text/plain
Expires
Thu, Nov 7, 06:42 (20 h, 13 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2232704
Default Alt Text
D809.diff (2 KB)

Event Timeline