1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2025-12-12 17:44:04 +00:00

Minor refactor

This commit is contained in:
Samuel Štancl 2019-01-28 18:34:26 +01:00
parent 7ce9613a68
commit e919c6e25b

View file

@ -22,14 +22,14 @@ class TenantManager
*
* @var StorageDriver
*/
public $storage;
private $storage;
/**
* Database manager.
*
* @var DatabaseManager
*/
public $database;
private $database;
/**
* Current tenant.
@ -225,13 +225,18 @@ class TenantManager
*/
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).");
}
$uuid = $this->tenant['uuid'];
// If $uuid is the uuid of the current tenant, put
// the value into the $this->tenant array as well.
$target = []; // black hole
if (($this->tenant['uuid'] ?? null) === $uuid) {
$target = &$this->tenant;
} else {
$target = []; // black hole
}
if (! is_null($value)) {