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:
parent
b1e91f1029
commit
65beecf265
1 changed files with 9 additions and 0 deletions
|
|
@ -11,6 +11,8 @@ use Illuminate\Foundation\Application;
|
||||||
use Stancl\Tenancy\Contracts\TenancyBootstrapper;
|
use Stancl\Tenancy\Contracts\TenancyBootstrapper;
|
||||||
use Stancl\Tenancy\Contracts\Tenant;
|
use Stancl\Tenancy\Contracts\Tenant;
|
||||||
use Stancl\Tenancy\Overrides\TenancyBroadcastManager;
|
use Stancl\Tenancy\Overrides\TenancyBroadcastManager;
|
||||||
|
use Illuminate\Support\Facades\Broadcast;
|
||||||
|
use Illuminate\Contracts\Broadcasting\Factory as BroadcastingFactory;
|
||||||
|
|
||||||
class BroadcastingConfigBootstrapper implements TenancyBootstrapper
|
class BroadcastingConfigBootstrapper implements TenancyBootstrapper
|
||||||
{
|
{
|
||||||
|
|
@ -81,6 +83,10 @@ class BroadcastingConfigBootstrapper implements TenancyBootstrapper
|
||||||
$this->app->extend(Broadcaster::class, function (Broadcaster $broadcaster) {
|
$this->app->extend(Broadcaster::class, function (Broadcaster $broadcaster) {
|
||||||
return $this->app->make(BroadcastManager::class)->connection();
|
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
|
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(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);
|
||||||
|
|
||||||
|
// Clear the resolved Broadcast facade instance so that it gets re-resolved as the central broadcast manager
|
||||||
|
Broadcast::clearResolvedInstance(BroadcastingFactory::class);
|
||||||
|
|
||||||
$this->unsetConfig();
|
$this->unsetConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue