TenantContext
in package
FinalYes
Tracks the active tenant for the current request, worker message, or CLI scope.
Table of Contents
Properties
- $stack : array<int, TenantMetadata>
Methods
- current() : TenantMetadata
- Return the active tenant or fail fast if code is not tenant-scoped.
- id() : string
- Return the active tenant id.
- slug() : string
- Return the active tenant slug.
- tryCurrent() : TenantMetadata|null
- Return the active tenant when one is set.
- with() : TReturn
- Run a callback with the supplied tenant context and always restore the previous context.
- __construct() : mixed
- Static utility class.
Properties
$stack
private
static array<int, TenantMetadata>
$stack
= []
Methods
current()
Return the active tenant or fail fast if code is not tenant-scoped.
public
static current() : TenantMetadata
Return values
TenantMetadataid()
Return the active tenant id.
public
static id() : string
Return values
stringslug()
Return the active tenant slug.
public
static slug() : string
Return values
stringtryCurrent()
Return the active tenant when one is set.
public
static tryCurrent() : TenantMetadata|null
Return values
TenantMetadata|nullwith()
Run a callback with the supplied tenant context and always restore the previous context.
public
static with(TenantMetadata $tenant, callable(): TReturn $callback) : TReturn
Parameters
- $tenant : TenantMetadata
-
Tenant metadata
- $callback : callable(): TReturn
-
Callback to run
Tags
Return values
TReturn__construct()
Static utility class.
private
__construct() : mixed