1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2025-12-12 20:34:03 +00:00

[2.2.0] [WIP] Add functionality (#206)

* TenantDatabaseDoesNotExistException

* Apply fixes from StyleCI

* User post-creation callbacks

* Rename method

* postCreationActions

* pass $tenant as parameter

* pass $tenant to async actions

* WIP findBy()

* findBy\* ForwardsCalls

* Apply fixes from StyleCI

* findBy DB storage driver

* Redis  SD TODO message

* Apply fixes from StyleCI

* Fix chained jobs

* WIP event system

* import str

* instanceof closure check

* findBy instead of find

* Tenant -> Tenants

* dots

* Use DB hooks instead of a SC key

* Don't allow  callables for queue chain

* CanDeleteKeys interface

* Apply fixes from StyleCI

* CanFindByAnyKey interface

* Apply fixes from StyleCI

* Ditch models for custom repositories

* Resolve circular dependency

* Apply fixes from StyleCI

* Fix tests

* Apply fixes from StyleCI

* FutureTest

* Prefix tenant events with 'tenant.'

* Event listener arguments test
This commit is contained in:
Samuel Štancl 2019-10-27 21:10:41 +01:00 committed by GitHub
parent 7389f44de9
commit 869ac32983
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
22 changed files with 654 additions and 254 deletions

View file

@ -9,8 +9,10 @@ use Closure;
use Illuminate\Foundation\Application;
use Illuminate\Support\Str;
use Illuminate\Support\Traits\ForwardsCalls;
use Stancl\Tenancy\Contracts\Future\CanDeleteKeys;
use Stancl\Tenancy\Contracts\StorageDriver;
use Stancl\Tenancy\Contracts\UniqueIdentifierGenerator;
use Stancl\Tenancy\Exceptions\NotImplementedException;
use Stancl\Tenancy\Exceptions\TenantStorageException;
/**
@ -349,6 +351,39 @@ class Tenant implements ArrayAccess
return $this->put($key, $value);
}
/**
* Delete a key from the tenant's storage.
*
* @param string $key
* @return self
*/
public function deleteKey(string $key): self
{
return $this->deleteKeys([$key]);
}
/**
* Delete keys from the tenant's storage.
*
* @param string[] $keys
* @return self
*/
public function deleteKeys(array $keys): self
{
if (! $this->storage instanceof CanDeleteKeys) {
throw new NotImplementedException(get_class($this->storage), 'deleteMany',
'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.'
);
} else {
$this->storage->deleteMany($keys);
foreach ($keys as $key) {
unset($this->data[$key]);
}
}
return $this;
}
/**
* Set a value.
*