mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-12 22:54:03 +00:00
Bugfix
put() stored the value for the current tenant even if the specified $uuid was of a different tenant
This commit is contained in:
parent
e8f2e62645
commit
2d12a6f05f
1 changed files with 9 additions and 2 deletions
|
|
@ -226,16 +226,23 @@ 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'];
|
$uuid = $uuid ?: $this->tenant['uuid'];
|
||||||
|
|
||||||
|
// If $uuid is the uuid of the current tenant, put
|
||||||
|
// the value into the $this->tenant array as well.
|
||||||
|
$target = [];
|
||||||
|
if (($this->tenant['uuid'] ?? null) === $uuid) {
|
||||||
|
$target = &$this->tenant;
|
||||||
|
}
|
||||||
|
|
||||||
if (! is_null($value)) {
|
if (! is_null($value)) {
|
||||||
return $this->tenant[$key] = $this->storage->put($uuid, $key, $value);
|
return $target[$key] = $this->storage->put($uuid, $key, $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! is_array($key)) {
|
if (! is_array($key)) {
|
||||||
throw new \Exception("No value supplied for key $key.");
|
throw new \Exception("No value supplied for key $key.");
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->tenant[$key] = $this->storage->putMany($uuid, $key);
|
return $target[$key] = $this->storage->putMany($uuid, $key);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue