mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-12 20:34:03 +00:00
Minor refactor
This commit is contained in:
parent
7ce9613a68
commit
e919c6e25b
1 changed files with 13 additions and 8 deletions
|
|
@ -22,14 +22,14 @@ class TenantManager
|
||||||
*
|
*
|
||||||
* @var StorageDriver
|
* @var StorageDriver
|
||||||
*/
|
*/
|
||||||
public $storage;
|
private $storage;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Database manager.
|
* Database manager.
|
||||||
*
|
*
|
||||||
* @var DatabaseManager
|
* @var DatabaseManager
|
||||||
*/
|
*/
|
||||||
public $database;
|
private $database;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Current tenant.
|
* Current tenant.
|
||||||
|
|
@ -225,13 +225,18 @@ class TenantManager
|
||||||
*/
|
*/
|
||||||
public function put($key, $value = null, string $uuid = null)
|
public function put($key, $value = null, string $uuid = null)
|
||||||
{
|
{
|
||||||
$uuid = $uuid ?: $this->tenant['uuid'];
|
if (is_null($uuid)) {
|
||||||
|
if (! isset($this->tenant['uuid'])) {
|
||||||
|
throw new \Exception("No UUID supplied (and no tenant is currently identified).");
|
||||||
|
}
|
||||||
|
|
||||||
// If $uuid is the uuid of the current tenant, put
|
$uuid = $this->tenant['uuid'];
|
||||||
// the value into the $this->tenant array as well.
|
|
||||||
$target = []; // black hole
|
// If $uuid is the uuid of the current tenant, put
|
||||||
if (($this->tenant['uuid'] ?? null) === $uuid) {
|
// the value into the $this->tenant array as well.
|
||||||
$target = &$this->tenant;
|
$target = &$this->tenant;
|
||||||
|
} else {
|
||||||
|
$target = []; // black hole
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! is_null($value)) {
|
if (! is_null($value)) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue