mirror of
https://github.com/archtechx/tenancy.git
synced 2026-05-07 14:04:03 +00:00
BroadcastingConfigBootstrapper and TenancyBroadcastManager: comments
This commit is contained in:
parent
29dd23db61
commit
4937a74ed5
2 changed files with 35 additions and 13 deletions
|
|
@ -8,13 +8,26 @@ use Illuminate\Broadcasting\Broadcasters\Broadcaster;
|
|||
use Illuminate\Broadcasting\BroadcastManager;
|
||||
use Illuminate\Contracts\Broadcasting\Broadcaster as BroadcasterContract;
|
||||
|
||||
/**
|
||||
* BroadcastManager override that always re-resolves the broadcasters in static::$tenantBroadcasters
|
||||
* when attempting to retrieve them and passes the channels of the original (central) broadcaster
|
||||
* to the broadcasters newly resolved in tenant context.
|
||||
*
|
||||
* Affects calls that use app(BroadcastManager::class)->get().
|
||||
*
|
||||
* @see Stancl\Tenancy\Bootstrappers\BroadcastingConfigBootstrapper
|
||||
*/
|
||||
class TenancyBroadcastManager extends BroadcastManager
|
||||
{
|
||||
/**
|
||||
* Names of broadcasters that
|
||||
* - should always be recreated using $this->resolve(), even when they're cached and available
|
||||
* in $this->drivers (so that e.g. when you update broadcasting credentials in the tenant context,
|
||||
* the updated credentials will be used for broadcasting in the same context)
|
||||
* in $this->drivers so that when you update broadcasting config in the tenant context,
|
||||
* the updated config/credentials will be used for broadcasting in the same context.
|
||||
* Note that in cases like this, only direct config changes are reflected immediately.
|
||||
* For the broadcasters to reflect tenant property changes made in tenant context,
|
||||
* you still have to reinitialize tenancy after updating the tenant properties intended
|
||||
* for broadcasting config mapping, since the properties are only mapped to config on BroadcastingConfigBootstrapper::bootstrap().
|
||||
* - should inherit the original broadcaster's channels (= the channels registered in
|
||||
* the central context, e.g. in routes/channels.php, before this manager overrides the bound BroadcastManager).
|
||||
*/
|
||||
|
|
@ -46,9 +59,9 @@ class TenancyBroadcastManager extends BroadcastManager
|
|||
}
|
||||
|
||||
// The newly resolved broadcasters don't automatically receive the channels registered
|
||||
// in central context (e.g. in routes/channels.php), so the channels have to be obtained from the
|
||||
// broadcaster used in central context and manually passed to the new broadcasters
|
||||
// (attempting to broadcast using a broadcaster with no channels results in a 403 error).
|
||||
// in central context (e.g. Broadcast::channel() in routes/channels.php), so the channels
|
||||
// have to be obtained from the original (central) broadcaster and manually passed to the new broadcasters
|
||||
// (broadcasting using a broadcaster with no channels results in a 403 error on Broadcast::auth()).
|
||||
protected function passChannelsFromOriginalBroadcaster(Broadcaster $originalBroadcaster, Broadcaster $newBroadcaster): void
|
||||
{
|
||||
// invade() because channels can't be retrieved through any of the broadcaster's public methods
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue