mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-13 08:44:03 +00:00
TenantStorageException
This commit is contained in:
parent
5fb11dfc9f
commit
e25a01a997
3 changed files with 10 additions and 5 deletions
|
|
@ -6,9 +6,6 @@ namespace Stancl\Tenancy\Contracts;
|
||||||
|
|
||||||
use Stancl\Tenancy\Tenant;
|
use Stancl\Tenancy\Tenant;
|
||||||
|
|
||||||
// todo this class now manages types (json encoding)
|
|
||||||
// make sure ids are not json encoded
|
|
||||||
|
|
||||||
interface StorageDriver
|
interface StorageDriver
|
||||||
{
|
{
|
||||||
public function createTenant(Tenant $tenant): void;
|
public function createTenant(Tenant $tenant): void;
|
||||||
|
|
|
||||||
6
src/Exceptions/TenantStorageException.php
Normal file
6
src/Exceptions/TenantStorageException.php
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Stancl\Tenancy\Exceptions;
|
||||||
|
|
||||||
|
class TenantStorageException extends \Exception
|
||||||
|
{}
|
||||||
|
|
@ -7,6 +7,7 @@ namespace Stancl\Tenancy;
|
||||||
use ArrayAccess;
|
use ArrayAccess;
|
||||||
use Stancl\Tenancy\Contracts\StorageDriver;
|
use Stancl\Tenancy\Contracts\StorageDriver;
|
||||||
use Stancl\Tenancy\Contracts\UniqueIdentifierGenerator;
|
use Stancl\Tenancy\Contracts\UniqueIdentifierGenerator;
|
||||||
|
use Stancl\Tenancy\Exceptions\TenantStorageException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @internal Class is subject to breaking changes in minor and patch versions.
|
* @internal Class is subject to breaking changes in minor and patch versions.
|
||||||
|
|
@ -209,8 +210,9 @@ class Tenant implements ArrayAccess
|
||||||
|
|
||||||
public function put($key, $value = null): self
|
public function put($key, $value = null): self
|
||||||
{
|
{
|
||||||
// todo something like if ($this->storage->getIdKey() === $key) throw new Exception("Can't override ID")?
|
if ($this->storage->getIdKey() === $key) {
|
||||||
// and the responsibility of not overriding domains is up to the storage driver
|
throw new TenantStorageException("The tenant's id can't be changed.");
|
||||||
|
}
|
||||||
|
|
||||||
if (is_array($key)) {
|
if (is_array($key)) {
|
||||||
$this->storage->putMany($key);
|
$this->storage->putMany($key);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue