final class TenantManager (View source)

Traits

Properties

protected callable[][] $listeners

Event listeners.

from  TenantManagerEvents
protected callable[][] $integrationListeners

Integration listeners.

from  TenantManagerEvents
$originalSettings from  BootstrapsTenancy
bool $initialized

Was tenancy initialized/bootstrapped?

from  BootstrapsTenancy
protected Application $app

The application instance.

StorageDriver $storage

Storage driver for tenant metadata.

DatabaseManager $database

Database manager.

protected UniqueIdentifierGenerator $generator

Unique identifier generator.

array $tenant

Current tenant.

Methods

bootstrapping(callable $callback)

Register a listener that will be executed before tenancy is bootstrapped.

bootstrapped(callable $callback)

Register a listener that will be executed after tenancy is bootstrapped.

ending(callable $callback)

Register a listener that will be executed before tenancy is ended.

ended(callable $callback)

Register a listener that will be executed after tenancy is ended.

Collection
event(string $name)

Fire an event.

void
integrationEvent(string $name, callable $callback)

Register a callback for an integration event.

callable[]
integration(string $name, ...$arguments)

Return callbacks for an integration event.

bootstrap()

No description

end()

No description

setPhpRedisPrefix($connections = ['default'])

No description

resetPhpRedisPrefix($connections = ['default'])

No description

tagCache()

No description

untagCache()

No description

__construct(Application $app, StorageDriver $storage, DatabaseManager $database, UniqueIdentifierGenerator $generator)

No description

array
init(string $domain = null)

No description

array
identify(string $domain = null)

No description

array
create(string $domain = null, array $data = [])

Create a tenant.

generateUniqueIdentifier(string $domain, array $data)

No description

bool
delete(string $uuid)

No description

array
getTenantById(string $uuid, array|string $fields = [])

Return an array with information about a tenant based on his uuid.

array
find(string $uuid, array|string $fields = [])

Alias for getTenantById().

string|null
getTenantIdByDomain(string $domain = null)

Get tenant uuid based on the domain that belongs to him.

string|null
getIdByDomain(string $domain = null)

Alias for getTenantIdByDomain().

array
findByDomain(string $domain = null, mixed $fields = [])

Get tenant information based on his domain.

static string|null
currentDomain()

No description

string
getDatabaseName($tenant = [])

No description

array
setTenant(array $tenant)

Set the tenant property to a JSON decoded version of the tenant's data obtained from storage.

void
disconnectDatabase()

Reconnects to the default database.

Collection
all(array|string $uuids = [])

Get all tenants.

array
initById(string $uuid)

Initialize tenancy based on tenant uuid.

mixed
get(string|array $key, string $uuid = null)

Get a value from the storage for a tenant.

mixed
put(string|array $key, mixed $value = null, string $uuid = null)

Puts a value into the storage for a tenant.

mixed
set(string|array $key, mixed $value = null, string $uuid = null)

Alias for put().

jsonDecodeArrayValues(array $array)

No description

useJson()

No description

mixed
__invoke(string $attribute)

Return the identified tenant's attribute(s).

Details

TenantManagerEvents bootstrapping(callable $callback)

Register a listener that will be executed before tenancy is bootstrapped.

Parameters

callable $callback

Return Value

TenantManagerEvents

TenantManagerEvents bootstrapped(callable $callback)

Register a listener that will be executed after tenancy is bootstrapped.

Parameters

callable $callback

Return Value

TenantManagerEvents

TenantManagerEvents ending(callable $callback)

Register a listener that will be executed before tenancy is ended.

Parameters

callable $callback

Return Value

TenantManagerEvents

TenantManagerEvents ended(callable $callback)

Register a listener that will be executed after tenancy is ended.

Parameters

callable $callback

Return Value

TenantManagerEvents

Collection event(string $name)

Fire an event.

Parameters

string $name

Event name

Return Value

Collection

Prevented events

void integrationEvent(string $name, callable $callback)

Register a callback for an integration event.

Parameters

string $name
callable $callback

Return Value

void

callable[] integration(string $name, ...$arguments)

Return callbacks for an integration event.

Parameters

string $name
...$arguments

Return Value

callable[]

bootstrap()

No description

end()

No description

switchDatabaseConnection()

No description

setPhpRedisPrefix($connections = ['default'])

No description

Parameters

$connections

resetPhpRedisPrefix($connections = ['default'])

No description

Parameters

$connections

tagCache()

No description

untagCache()

No description

suffixFilesystemRootPaths()

No description

resetFilesystemRootPaths()

No description

__construct(Application $app, StorageDriver $storage, DatabaseManager $database, UniqueIdentifierGenerator $generator)

No description

Parameters

Application $app
StorageDriver $storage
DatabaseManager $database
UniqueIdentifierGenerator $generator

array init(string $domain = null)

No description

Parameters

string $domain

Return Value

array

array identify(string $domain = null)

No description

Parameters

string $domain

Return Value

array

array create(string $domain = null, array $data = [])

Create a tenant.

Parameters

string $domain
array $data

Return Value

array

generateUniqueIdentifier(string $domain, array $data)

No description

Parameters

string $domain
array $data

bool delete(string $uuid)

No description

Parameters

string $uuid

Return Value

bool

array getTenantById(string $uuid, array|string $fields = [])

Return an array with information about a tenant based on his uuid.

Parameters

string $uuid
array|string $fields

Return Value

array

array find(string $uuid, array|string $fields = [])

Alias for getTenantById().

Parameters

string $uuid
array|string $fields

Return Value

array

string|null getTenantIdByDomain(string $domain = null)

Get tenant uuid based on the domain that belongs to him.

Parameters

string $domain

Return Value

string|null

string|null getIdByDomain(string $domain = null)

Alias for getTenantIdByDomain().

Parameters

string $domain

Return Value

string|null

array findByDomain(string $domain = null, mixed $fields = [])

Get tenant information based on his domain.

Parameters

string $domain
mixed $fields

Return Value

array

static string|null currentDomain()

No description

Return Value

string|null

string getDatabaseName($tenant = [])

No description

Parameters

$tenant

Return Value

string

array setTenant(array $tenant)

Set the tenant property to a JSON decoded version of the tenant's data obtained from storage.

Parameters

array $tenant

Return Value

array

void disconnectDatabase()

Reconnects to the default database.

More descriptive name?

Return Value

void

Collection all(array|string $uuids = [])

Get all tenants.

Parameters

array|string $uuids

Return Value

Collection

array initById(string $uuid)

Initialize tenancy based on tenant uuid.

Parameters

string $uuid

Return Value

array

mixed get(string|array $key, string $uuid = null)

Get a value from the storage for a tenant.

Parameters

string|array $key
string $uuid

Return Value

mixed

mixed put(string|array $key, mixed $value = null, string $uuid = null)

Puts a value into the storage for a tenant.

Parameters

string|array $key
mixed $value
string $uuid

Return Value

mixed

mixed set(string|array $key, mixed $value = null, string $uuid = null)

Alias for put().

Parameters

string|array $key
mixed $value
string $uuid

Return Value

mixed

protected jsonDecodeArrayValues(array $array)

No description

Parameters

array $array

useJson()

No description

mixed __invoke(string $attribute)

Return the identified tenant's attribute(s).

Deprecate this in v2.

Parameters

string $attribute

Return Value

mixed