1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2026-05-06 18:04:03 +00:00

BroadcastingConfigBootstrapper: clear the Broadcast facade's resolved Broadcasting\Factory instance

After initializing tenancy, calls like `Broadcast::auth()` use the central `BroadcastManager`. Clearing the facade's resolved `Broadcasting\Factory` instance fixes that problem.
This commit is contained in:
lukinovec 2026-03-31 16:32:33 +02:00
parent b1e91f1029
commit 65beecf265

View file

@ -11,6 +11,8 @@ use Illuminate\Foundation\Application;
use Stancl\Tenancy\Contracts\TenancyBootstrapper;
use Stancl\Tenancy\Contracts\Tenant;
use Stancl\Tenancy\Overrides\TenancyBroadcastManager;
use Illuminate\Support\Facades\Broadcast;
use Illuminate\Contracts\Broadcasting\Factory as BroadcastingFactory;
class BroadcastingConfigBootstrapper implements TenancyBootstrapper
{
@ -81,6 +83,10 @@ class BroadcastingConfigBootstrapper implements TenancyBootstrapper
$this->app->extend(Broadcaster::class, function (Broadcaster $broadcaster) {
return $this->app->make(BroadcastManager::class)->connection();
});
// Clear the resolved Broadcast facade instance so that it gets re-resolved as the tenant broadcast manager
// when used (e.g. in BroadcastController::authenticate)
Broadcast::clearResolvedInstance(BroadcastingFactory::class);
}
public function revert(): void
@ -89,6 +95,9 @@ class BroadcastingConfigBootstrapper implements TenancyBootstrapper
$this->app->singleton(BroadcastManager::class, fn (Application $app) => $this->originalBroadcastManager);
$this->app->singleton(Broadcaster::class, fn (Application $app) => $this->originalBroadcaster);
// Clear the resolved Broadcast facade instance so that it gets re-resolved as the central broadcast manager
Broadcast::clearResolvedInstance(BroadcastingFactory::class);
$this->unsetConfig();
}