1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2026-02-05 17:14:03 +00:00

Add BroadcastTenancyBootstrapper comments

This commit is contained in:
lukinovec 2022-12-15 07:47:52 +01:00
parent 85680622f4
commit cfb7e9674c

View file

@ -58,15 +58,20 @@ class BroadcastTenancyBootstrapper implements TenancyBootstrapper
$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) {
$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());
});
}
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(Broadcaster::class, fn (Application $app) => $this->originalBroadcaster);