Skip to content

Commit 0e89f3e

Browse files
committed
Merge branch '8.x'
# Conflicts: # CHANGELOG-8.x.md # composer.json # src/Illuminate/Foundation/Application.php # src/Illuminate/Routing/UrlGenerator.php # tests/Integration/Routing/UrlSigningTest.php
2 parents fc46309 + 71a99f1 commit 0e89f3e

File tree

139 files changed

+3953
-245
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

139 files changed

+3953
-245
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989
"orchestra/testbench-core": "^7.0",
9090
"pda/pheanstalk": "^4.0",
9191
"phpunit/phpunit": "^9.4",
92-
"predis/predis": "^1.1.1",
92+
"predis/predis": "^1.1.2",
9393
"symfony/cache": "^5.3"
9494
},
9595
"provide": {

src/Illuminate/Auth/Authenticatable.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,16 @@ public function getAuthIdentifier()
3131
return $this->{$this->getAuthIdentifierName()};
3232
}
3333

34+
/**
35+
* Get the unique broadcast identifier for the user.
36+
*
37+
* @return mixed
38+
*/
39+
public function getAuthIdentifierForBroadcasting()
40+
{
41+
return $this->getAuthIdentifier();
42+
}
43+
3444
/**
3545
* Get the password for the user.
3646
*

src/Illuminate/Broadcasting/BroadcastEvent.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,14 @@ public function handle(Broadcaster $broadcaster)
6060
$name = method_exists($this->event, 'broadcastAs')
6161
? $this->event->broadcastAs() : get_class($this->event);
6262

63+
$channels = Arr::wrap($this->event->broadcastOn());
64+
65+
if (empty($channels)) {
66+
return;
67+
}
68+
6369
$broadcaster->broadcast(
64-
Arr::wrap($this->event->broadcastOn()), $name,
70+
$channels, $name,
6571
$this->getPayloadFromEvent($this->event)
6672
);
6773
}

src/Illuminate/Broadcasting/Broadcasters/AblyBroadcaster.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,17 @@ public function validAuthenticationResponse($request, $result)
7272

7373
$channelName = $this->normalizeChannelName($request->channel_name);
7474

75+
$user = $this->retrieveUser($request, $channelName);
76+
77+
$broadcastIdentifier = method_exists($user, 'getAuthIdentifierForBroadcasting')
78+
? $user->getAuthIdentifierForBroadcasting()
79+
: $user->getAuthIdentifier();
80+
7581
$signature = $this->generateAblySignature(
7682
$request->channel_name,
7783
$request->socket_id,
7884
$userData = array_filter([
79-
'user_id' => (string) $this->retrieveUser($request, $channelName)->getAuthIdentifier(),
85+
'user_id' => (string) $broadcastIdentifier,
8086
'user_info' => $result,
8187
])
8288
);

src/Illuminate/Broadcasting/Broadcasters/Broadcaster.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Exception;
66
use Illuminate\Container\Container;
77
use Illuminate\Contracts\Broadcasting\Broadcaster as BroadcasterContract;
8+
use Illuminate\Contracts\Broadcasting\HasBroadcastChannel;
89
use Illuminate\Contracts\Routing\BindingRegistrar;
910
use Illuminate\Contracts\Routing\UrlRoutable;
1011
use Illuminate\Support\Arr;
@@ -40,13 +41,19 @@ abstract class Broadcaster implements BroadcasterContract
4041
/**
4142
* Register a channel authenticator.
4243
*
43-
* @param string $channel
44+
* @param \Illuminate\Contracts\Broadcasting\HasBroadcastChannel|string $channel
4445
* @param callable|string $callback
4546
* @param array $options
4647
* @return $this
4748
*/
4849
public function channel($channel, $callback, $options = [])
4950
{
51+
if ($channel instanceof HasBroadcastChannel) {
52+
$channel = $channel->broadcastChannelRoute();
53+
} elseif (is_string($channel) && class_exists($channel) && is_a($channel, HasBroadcastChannel::class, true)) {
54+
$channel = (new $channel)->broadcastChannelRoute();
55+
}
56+
5057
$this->channels[$channel] = $callback;
5158

5259
$this->channelOptions[$channel] = $options;

src/Illuminate/Broadcasting/Broadcasters/PusherBroadcaster.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,17 @@ public function validAuthenticationResponse($request, $result)
7171

7272
$channelName = $this->normalizeChannelName($request->channel_name);
7373

74+
$user = $this->retrieveUser($request, $channelName);
75+
76+
$broadcastIdentifier = method_exists($user, 'getAuthIdentifierForBroadcasting')
77+
? $user->getAuthIdentifierForBroadcasting()
78+
: $user->getAuthIdentifier();
79+
7480
return $this->decodePusherResponse(
7581
$request,
7682
$this->pusher->presence_auth(
7783
$request->channel_name, $request->socket_id,
78-
$this->retrieveUser($request, $channelName)->getAuthIdentifier(), $result
84+
$broadcastIdentifier, $result
7985
)
8086
);
8187
}
@@ -137,7 +143,7 @@ public function getPusher()
137143
/**
138144
* Set the Pusher SDK instance.
139145
*
140-
* @param \Pusher\Pusher $pusher
146+
* @param \Pusher\Pusher $pusher
141147
* @return void
142148
*/
143149
public function setPusher($pusher)

src/Illuminate/Broadcasting/Broadcasters/RedisBroadcaster.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,14 @@ public function validAuthenticationResponse($request, $result)
8686

8787
$channelName = $this->normalizeChannelName($request->channel_name);
8888

89+
$user = $this->retrieveUser($request, $channelName);
90+
91+
$broadcastIdentifier = method_exists($user, 'getAuthIdentifierForBroadcasting')
92+
? $user->getAuthIdentifierForBroadcasting()
93+
: $user->getAuthIdentifier();
94+
8995
return json_encode(['channel_data' => [
90-
'user_id' => $this->retrieveUser($request, $channelName)->getAuthIdentifier(),
96+
'user_id' => $broadcastIdentifier,
9197
'user_info' => $result,
9298
]]);
9399
}

src/Illuminate/Broadcasting/Channel.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
namespace Illuminate\Broadcasting;
44

5+
use Illuminate\Contracts\Broadcasting\HasBroadcastChannel;
6+
57
class Channel
68
{
79
/**
@@ -14,12 +16,12 @@ class Channel
1416
/**
1517
* Create a new channel instance.
1618
*
17-
* @param string $name
19+
* @param \Illuminate\Contracts\Broadcasting\HasBroadcastChannel|string $name
1820
* @return void
1921
*/
2022
public function __construct($name)
2123
{
22-
$this->name = $name;
24+
$this->name = $name instanceof HasBroadcastChannel ? $name->broadcastChannel() : $name;
2325
}
2426

2527
/**

src/Illuminate/Broadcasting/PrivateChannel.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,20 @@
22

33
namespace Illuminate\Broadcasting;
44

5+
use Illuminate\Contracts\Broadcasting\HasBroadcastChannel;
6+
57
class PrivateChannel extends Channel
68
{
79
/**
810
* Create a new channel instance.
911
*
10-
* @param string $name
12+
* @param \Illuminate\Contracts\Broadcasting\HasBroadcastChannel|string $name
1113
* @return void
1214
*/
1315
public function __construct($name)
1416
{
17+
$name = $name instanceof HasBroadcastChannel ? $name->broadcastChannel() : $name;
18+
1519
parent::__construct('private-'.$name);
1620
}
1721
}

src/Illuminate/Bus/Dispatcher.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,8 @@ protected function commandShouldBeQueued($command)
209209
*
210210
* @param mixed $command
211211
* @return mixed
212+
*
213+
* @throws \RuntimeException
212214
*/
213215
public function dispatchToQueue($command)
214216
{

0 commit comments

Comments
 (0)