From e25a01a99768629f239068e3f6160256b6c061ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20=C5=A0tancl?= Date: Sun, 15 Sep 2019 12:16:45 +0200 Subject: [PATCH] TenantStorageException --- src/Contracts/StorageDriver.php | 3 --- src/Exceptions/TenantStorageException.php | 6 ++++++ src/Tenant.php | 6 ++++-- 3 files changed, 10 insertions(+), 5 deletions(-) create mode 100644 src/Exceptions/TenantStorageException.php diff --git a/src/Contracts/StorageDriver.php b/src/Contracts/StorageDriver.php index c0ceec82..a974fe04 100644 --- a/src/Contracts/StorageDriver.php +++ b/src/Contracts/StorageDriver.php @@ -6,9 +6,6 @@ namespace Stancl\Tenancy\Contracts; use Stancl\Tenancy\Tenant; -// todo this class now manages types (json encoding) -// make sure ids are not json encoded - interface StorageDriver { public function createTenant(Tenant $tenant): void; diff --git a/src/Exceptions/TenantStorageException.php b/src/Exceptions/TenantStorageException.php new file mode 100644 index 00000000..5e4a084d --- /dev/null +++ b/src/Exceptions/TenantStorageException.php @@ -0,0 +1,6 @@ +storage->getIdKey() === $key) throw new Exception("Can't override ID")? - // and the responsibility of not overriding domains is up to the storage driver + if ($this->storage->getIdKey() === $key) { + throw new TenantStorageException("The tenant's id can't be changed."); + } if (is_array($key)) { $this->storage->putMany($key);