From 40f30f1a2131904eb4f6e6c456823e7b2cb726eb Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Wed, 21 Dec 2016 08:11:27 -0600 Subject: [PATCH] rework broadcast message --- .../Channels/BroadcastChannel.php | 3 ++- .../Events/BroadcastNotificationCreated.php | 3 ++- .../Messages/BroadcastMessage.php | 23 ++++--------------- .../NotificationBroadcastChannelTest.php | 2 +- 4 files changed, 9 insertions(+), 22 deletions(-) diff --git a/src/Illuminate/Notifications/Channels/BroadcastChannel.php b/src/Illuminate/Notifications/Channels/BroadcastChannel.php index cb3f860581e3..dd6dc987f31d 100644 --- a/src/Illuminate/Notifications/Channels/BroadcastChannel.php +++ b/src/Illuminate/Notifications/Channels/BroadcastChannel.php @@ -44,7 +44,8 @@ public function send($notifiable, Notification $notification) ); if ($message instanceof BroadcastMessage) { - $event->connection = 'sync'; + $event->onConnection($message->connection) + ->onQueue($message->queue); } return $this->events->fire($event); diff --git a/src/Illuminate/Notifications/Events/BroadcastNotificationCreated.php b/src/Illuminate/Notifications/Events/BroadcastNotificationCreated.php index 2dc851ce1e1d..60dbae71b8d7 100644 --- a/src/Illuminate/Notifications/Events/BroadcastNotificationCreated.php +++ b/src/Illuminate/Notifications/Events/BroadcastNotificationCreated.php @@ -2,13 +2,14 @@ namespace Illuminate\Notifications\Events; +use Illuminate\Bus\Queueable; use Illuminate\Queue\SerializesModels; use Illuminate\Broadcasting\PrivateChannel; use Illuminate\Contracts\Broadcasting\ShouldBroadcast; class BroadcastNotificationCreated implements ShouldBroadcast { - use SerializesModels; + use Queueable, SerializesModels; /** * The notifiable entity who received the notification. diff --git a/src/Illuminate/Notifications/Messages/BroadcastMessage.php b/src/Illuminate/Notifications/Messages/BroadcastMessage.php index 6c6a06e6cb8d..5b7ed6860fcf 100644 --- a/src/Illuminate/Notifications/Messages/BroadcastMessage.php +++ b/src/Illuminate/Notifications/Messages/BroadcastMessage.php @@ -2,8 +2,12 @@ namespace Illuminate\Notifications\Messages; +use Illuminate\Bus\Queueable; + class BroadcastMessage { + use Queueable; + /** * The data for the notification. * @@ -11,13 +15,6 @@ class BroadcastMessage */ public $data; - /** - * Determine if the message should be broadcasted immediately. - * - * @var array - */ - public $broadcastNow = false; - /** * Create a new message instance. * @@ -41,16 +38,4 @@ public function data($data) return $this; } - - /** - * Broadcast this message immediately. - * - * @return $this - */ - public function now() - { - $this->broadcastNow = true; - - return $this; - } } diff --git a/tests/Notifications/NotificationBroadcastChannelTest.php b/tests/Notifications/NotificationBroadcastChannelTest.php index 98b33e1f2b11..b9621e168e52 100644 --- a/tests/Notifications/NotificationBroadcastChannelTest.php +++ b/tests/Notifications/NotificationBroadcastChannelTest.php @@ -83,6 +83,6 @@ public function toArray($notifiable) public function toBroadcast() { - return (new \Illuminate\Notifications\Messages\BroadcastMessage([]))->now(); + return (new \Illuminate\Notifications\Messages\BroadcastMessage([]))->onConnection('sync'); } }