mirror of
https://github.com/archtechx/tenancy.git
synced 2026-02-05 16:34:04 +00:00
Add BroadcastTenancyBootstrapper comments
This commit is contained in:
parent
85680622f4
commit
cfb7e9674c
1 changed files with 5 additions and 0 deletions
|
|
@ -58,15 +58,20 @@ class BroadcastTenancyBootstrapper implements TenancyBootstrapper
|
||||||
|
|
||||||
$this->setConfig($tenant);
|
$this->setConfig($tenant);
|
||||||
|
|
||||||
|
// Make BroadcastManager resolve to a custom BroadcastManager which makes the broadcasters use the tenant credentials
|
||||||
$this->app->extend(BroadcastManager::class, function (BroadcastManager $broadcastManager) {
|
$this->app->extend(BroadcastManager::class, function (BroadcastManager $broadcastManager) {
|
||||||
$tenancyBroadcastManager = new TenancyBroadcastManager($this->app);
|
$tenancyBroadcastManager = new TenancyBroadcastManager($this->app);
|
||||||
|
|
||||||
|
// Because the new custom TenancyBroadcastManager won't have the original broadcasters
|
||||||
|
// It also won't have the channels registered in routes/channels.php, and without these, broadcasting won't work
|
||||||
|
// So we pass the default broadcaster to the new TenancyBroadcastManager
|
||||||
return $tenancyBroadcastManager->setDriver($broadcastManager->getDefaultDriver(), $broadcastManager->driver());
|
return $tenancyBroadcastManager->setDriver($broadcastManager->getDefaultDriver(), $broadcastManager->driver());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public function revert(): void
|
public function revert(): void
|
||||||
{
|
{
|
||||||
|
// Change the BroadcastManager and Broadcaster singletons back to what they were before initializing tenancy
|
||||||
$this->app->singleton(BroadcastManager::class, fn (Application $app) => $this->originalBroadcastManager);
|
$this->app->singleton(BroadcastManager::class, fn (Application $app) => $this->originalBroadcastManager);
|
||||||
$this->app->singleton(Broadcaster::class, fn (Application $app) => $this->originalBroadcaster);
|
$this->app->singleton(Broadcaster::class, fn (Application $app) => $this->originalBroadcaster);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue