1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2026-08-06 09:34:03 +00:00

Explain extending BroadcasterContract better

This commit is contained in:
lukinovec 2026-07-13 17:19:16 +02:00
parent 81d41b4690
commit c07996ede0

View file

@ -89,6 +89,9 @@ class BroadcastingConfigBootstrapper implements TenancyBootstrapper
// Swap the currently bound Broadcaster singleton (resolved earlier with the central credentials) // Swap the currently bound Broadcaster singleton (resolved earlier with the central credentials)
// for the tenant BroadcastManager's default broadcaster, so that anything resolving the Broadcaster // for the tenant BroadcastManager's default broadcaster, so that anything resolving the Broadcaster
// contract gets the same tenant broadcaster that the manager uses, instead of the stale central one. // contract gets the same tenant broadcaster that the manager uses, instead of the stale central one.
// The closure runs immediately (the extended singleton is already resolved), and it's also what makes
// channel auth work in tenant context -- the broadcaster resolved here gets cached as the tenant
// manager's default driver and receives the central channel auth closures (see below).
$this->app->extend(BroadcasterContract::class, function (BroadcasterContract $centralBroadcaster) { $this->app->extend(BroadcasterContract::class, function (BroadcasterContract $centralBroadcaster) {
$tenantBroadcaster = $this->app->make(BroadcastManager::class)->connection(); $tenantBroadcaster = $this->app->make(BroadcastManager::class)->connection();