Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F3769101
D809.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D809.diff
View Options
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
Details
Attached
Mime Type
text/plain
Expires
Sun, Nov 24, 12:59 (10 h, 21 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2260194
Default Alt Text
D809.diff (2 KB)
Attached To
Mode
D809: Improve AMQPEventListener code style
Attached
Detach File
Event Timeline
Log In to Comment