diff --git a/src/Contracts/Future/CanDeleteKeys.php b/src/Contracts/Future/CanDeleteKeys.php index 990ed34e..50a46662 100644 --- a/src/Contracts/Future/CanDeleteKeys.php +++ b/src/Contracts/Future/CanDeleteKeys.php @@ -16,4 +16,4 @@ interface CanDeleteKeys * @return void */ public function deleteMany(array $keys, Tenant $tenant = null): void; -} \ No newline at end of file +} diff --git a/src/Contracts/Future/CanFindByAnyKey.php b/src/Contracts/Future/CanFindByAnyKey.php new file mode 100644 index 00000000..56cf77c1 --- /dev/null +++ b/src/Contracts/Future/CanFindByAnyKey.php @@ -0,0 +1,22 @@ +first(); if (! $tenant) { diff --git a/src/StorageDrivers/RedisStorageDriver.php b/src/StorageDrivers/RedisStorageDriver.php index 8d5fc14a..453bd030 100644 --- a/src/StorageDrivers/RedisStorageDriver.php +++ b/src/StorageDrivers/RedisStorageDriver.php @@ -84,8 +84,6 @@ class RedisStorageDriver implements StorageDriver, CanDeleteKeys return $this->makeTenant($data); } - // TODO find by * - public function getTenantIdByDomain(string $domain): ?string { return $this->redis->hget("domains:$domain", 'tenant_id') ?: null; diff --git a/src/TenantManager.php b/src/TenantManager.php index b6c27665..5e080cb9 100644 --- a/src/TenantManager.php +++ b/src/TenantManager.php @@ -10,6 +10,7 @@ use Illuminate\Foundation\Application; use Illuminate\Support\Collection; use Illuminate\Support\Str; use Illuminate\Support\Traits\ForwardsCalls; +use Stancl\Tenancy\Contracts\Future\CanFindByAnyKeys; use Stancl\Tenancy\Contracts\TenantCannotBeCreatedException; use Stancl\Tenancy\Exceptions\NotImplementedException; use Stancl\Tenancy\Exceptions\TenantCouldNotBeIdentifiedException; @@ -231,9 +232,9 @@ class TenantManager throw new Exception('No value supplied.'); } - if (! method_exists($this->storage, 'findBy')) { // todo use a contract instead + if (! $this->storage instanceof CanFindByAnyKeys) { throw new NotImplementedException(get_class($this->storage), 'findBy', - 'This method was added to storage drivers provided by the package in 2.2.0 and will be part of the StorageDriver contract in 3.0.0.' + 'This method was added to the DB storage driver provided by the package in 2.2.0 and might be part of the StorageDriver contract in 3.0.0.' ); }