From 03358bafa0b985eaee68ecfce6a22b1424c49de8 Mon Sep 17 00:00:00 2001 From: Alex Renoki Date: Mon, 31 Jan 2022 21:48:42 +0200 Subject: [PATCH 1/2] Expose pusher() and ably() --- .../Broadcasting/BroadcastManager.php | 32 ++++++++++++++++--- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/src/Illuminate/Broadcasting/BroadcastManager.php b/src/Illuminate/Broadcasting/BroadcastManager.php index 68ab16856c7e..f5f8a04c9e51 100644 --- a/src/Illuminate/Broadcasting/BroadcastManager.php +++ b/src/Illuminate/Broadcasting/BroadcastManager.php @@ -207,12 +207,12 @@ protected function callCustomCreator(array $config) } /** - * Create an instance of the driver. + * Get the Pusher instance associated to the config. * * @param array $config - * @return \Illuminate\Contracts\Broadcasting\Broadcaster + * @return \Pusher\Pusher */ - protected function createPusherDriver(array $config) + public function pusher(array $config) { $pusher = new Pusher( $config['key'], @@ -228,7 +228,29 @@ protected function createPusherDriver(array $config) $pusher->setLogger($this->app->make(LoggerInterface::class)); } - return new PusherBroadcaster($pusher); + return $pusher; + } + + /** + * Create an instance of the driver. + * + * @param array $config + * @return \Illuminate\Contracts\Broadcasting\Broadcaster + */ + protected function createPusherDriver(array $config) + { + return new PusherBroadcaster($this->pusher($config)); + } + + /** + * Get the Ably instance associated to the config. + * + * @param array $config + * @return \Ably\AblyRest + */ + public function ably(array $config) + { + return new AblyRest($config); } /** @@ -239,7 +261,7 @@ protected function createPusherDriver(array $config) */ protected function createAblyDriver(array $config) { - return new AblyBroadcaster(new AblyRest($config)); + return new AblyBroadcaster($this->ably($config)); } /** From f1cf3f95cbc491edea64094b83ac91a42b852e04 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Mon, 31 Jan 2022 16:25:21 -0600 Subject: [PATCH 2/2] formatitng --- .../Broadcasting/BroadcastManager.php | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/Illuminate/Broadcasting/BroadcastManager.php b/src/Illuminate/Broadcasting/BroadcastManager.php index f5f8a04c9e51..eecc32c107cd 100644 --- a/src/Illuminate/Broadcasting/BroadcastManager.php +++ b/src/Illuminate/Broadcasting/BroadcastManager.php @@ -207,7 +207,18 @@ protected function callCustomCreator(array $config) } /** - * Get the Pusher instance associated to the config. + * Create an instance of the driver. + * + * @param array $config + * @return \Illuminate\Contracts\Broadcasting\Broadcaster + */ + protected function createPusherDriver(array $config) + { + return new PusherBroadcaster($this->pusher($config)); + } + + /** + * Get a Pusher instance for the given configuration. * * @param array $config * @return \Pusher\Pusher @@ -237,13 +248,13 @@ public function pusher(array $config) * @param array $config * @return \Illuminate\Contracts\Broadcasting\Broadcaster */ - protected function createPusherDriver(array $config) + protected function createAblyDriver(array $config) { - return new PusherBroadcaster($this->pusher($config)); + return new AblyBroadcaster($this->ably($config)); } /** - * Get the Ably instance associated to the config. + * Get an Ably instance for the given configuration. * * @param array $config * @return \Ably\AblyRest @@ -253,17 +264,6 @@ public function ably(array $config) return new AblyRest($config); } - /** - * Create an instance of the driver. - * - * @param array $config - * @return \Illuminate\Contracts\Broadcasting\Broadcaster - */ - protected function createAblyDriver(array $config) - { - return new AblyBroadcaster($this->ably($config)); - } - /** * Create an instance of the driver. *