Skip to content

Commit ef476c5

Browse files
committed
Polish comments
1 parent c831393 commit ef476c5

2 files changed

Lines changed: 19 additions & 14 deletions

File tree

src/Bootstrappers/BroadcastingConfigBootstrapper.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public function bootstrap(Tenant $tenant): void
8888
return $tenantBroadcastManager;
8989
});
9090

91-
// Swap currently bound Broadcaster instance for one that's resolved through the tenant broadcast manager.
91+
// Swap currently bound Broadcaster instance for one that's resolved through the tenant BroadcastManager.
9292
// Note that updating broadcasting config (credentials) in tenant context doesn't update the credentials
9393
// used by the bound Broadcaster instance. If you need to e.g. send a notification in response to
9494
// updating tenant's broadcasting credentials in tenant context, it's recommended to
@@ -99,7 +99,7 @@ public function bootstrap(Tenant $tenant): void
9999

100100
// Clear the resolved Broadcast facade's Illuminate\Contracts\Broadcasting\Factory instance
101101
// so that it gets re-resolved as TenancyBroadcastManager instead of the central BroadcastManager
102-
// when used e.g. in the Broadcast::auth() call in BroadcastController::authenticate (/broadcasting/auth).
102+
// when used. E.g. the Broadcast::auth() call in BroadcastController::authenticate (/broadcasting/auth).
103103
Broadcast::clearResolvedInstance(BroadcastingFactory::class);
104104
}
105105

@@ -109,7 +109,7 @@ public function revert(): void
109109
$this->app->singleton(BroadcastManager::class, fn (Application $app) => $this->originalBroadcastManager);
110110
$this->app->singleton(Broadcaster::class, fn (Application $app) => $this->originalBroadcaster);
111111

112-
// Clear the resolved Broadcast facade instance so that it gets re-resolved as the central broadcast manager
112+
// Clear the resolved Broadcast facade instance so that it gets re-resolved as the central BroadcastManager
113113
Broadcast::clearResolvedInstance(BroadcastingFactory::class);
114114

115115
$this->unsetConfig();

src/Overrides/TenancyBroadcastManager.php

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
/**
1212
* BroadcastManager override that always re-resolves the broadcasters in static::$tenantBroadcasters
1313
* when attempting to retrieve them and passes the channels of the original (central) broadcaster
14-
* to the broadcasters newly resolved in tenant context.
14+
* to the newly resolved (tenant) broadcasters.
1515
*
1616
* Affects calls that use app(BroadcastManager::class)->get().
1717
*
@@ -23,19 +23,21 @@ class TenancyBroadcastManager extends BroadcastManager
2323
* Names of broadcasters that
2424
* - should always be recreated using $this->resolve(), even when they're cached and available
2525
* in $this->drivers so that when you update broadcasting config in the tenant context,
26-
* the updated config/credentials will be used for broadcasting in the same context.
27-
* Note that in cases like this, only direct config changes are reflected immediately.
26+
* the updated config/credentials will be used for broadcasting immediately.
27+
* Note that in cases like this, only direct config changes are reflected right away.
2828
* For the broadcasters to reflect tenant property changes made in tenant context,
2929
* you still have to reinitialize tenancy after updating the tenant properties intended
30-
* for broadcasting config mapping, since the properties are only mapped to config on BroadcastingConfigBootstrapper::bootstrap().
30+
* to be mapped to broadcasting config, since the properties are only mapped to config
31+
* on BroadcastingConfigBootstrapper::bootstrap().
3132
* - should inherit the original broadcaster's channels (= the channels registered in
3233
* the central context, e.g. in routes/channels.php, before this manager overrides the bound BroadcastManager).
3334
*/
3435
public static array $tenantBroadcasters = ['pusher', 'ably'];
3536

3637
/**
3738
* Override the get method so that the broadcasters in static::$tenantBroadcasters
38-
* receive the original (central) broadcaster's channels and always get freshly resolved.
39+
* - receive the original (central) broadcaster's channels
40+
* - always get freshly resolved.
3941
*/
4042
protected function get($name)
4143
{
@@ -45,9 +47,10 @@ protected function get($name)
4547
$newBroadcaster = $this->resolve($name);
4648

4749
// Give the channels of the original (central) broadcaster to the newly resolved one.
50+
//
4851
// Broadcasters only have to implement the Illuminate\Contracts\Broadcasting\Broadcaster contract
49-
// which doesn't require the channels property, so passing the channels is only
50-
// needed for Illuminate\Broadcasting\Broadcasters\Broadcaster instances.
52+
// which doesn't require the channels property, so passing the channels is only needed for
53+
// Illuminate\Broadcasting\Broadcasters\Broadcaster instances (= all the default broadcasters, e.g. PusherBroadcaster).
5154
if ($originalBroadcaster instanceof Broadcaster && $newBroadcaster instanceof Broadcaster) {
5255
$this->passChannelsFromOriginalBroadcaster($originalBroadcaster, $newBroadcaster);
5356
}
@@ -58,10 +61,12 @@ protected function get($name)
5861
return parent::get($name);
5962
}
6063

61-
// The newly resolved broadcasters don't automatically receive the channels registered
62-
// in central context (e.g. Broadcast::channel() in routes/channels.php), so the channels
63-
// have to be obtained from the original (central) broadcaster and manually passed to the new broadcasters
64-
// (broadcasting using a broadcaster with no channels results in a 403 error on Broadcast::auth()).
64+
/**
65+
* The newly resolved broadcasters don't automatically receive the channels registered
66+
* in central context (e.g. Broadcast::channel() in routes/channels.php), so the channels
67+
* have to be obtained from the original (central) broadcaster and manually passed to the new broadcasters
68+
* (broadcasting using a broadcaster with no channels results in a 403 error on Broadcast::auth()).
69+
*/
6570
protected function passChannelsFromOriginalBroadcaster(Broadcaster $originalBroadcaster, Broadcaster $newBroadcaster): void
6671
{
6772
// invade() because channels can't be retrieved through any of the broadcaster's public methods

0 commit comments

Comments
 (0)