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

Exceptions

This commit is contained in:
Samuel Štancl 2019-09-08 11:35:05 +02:00
parent 29ad8e60f9
commit 51fc3c7706

View file

@ -5,6 +5,7 @@ declare(strict_types=1);
namespace Stancl\Tenancy; namespace Stancl\Tenancy;
use Illuminate\Foundation\Application; use Illuminate\Foundation\Application;
use Stancl\Tenancy\Exceptions\TenantCouldNotBeIdentifiedException;
/** /**
* @internal Class is subject to breaking changes in minor and patch versions. * @internal Class is subject to breaking changes in minor and patch versions.
@ -19,14 +20,14 @@ class TenantManagerv2
protected $tenant; protected $tenant;
/** @var Application */ /** @var Application */
private $app; protected $app;
/** @var Contracts\StorageDriver */ /** @var Contracts\StorageDriver */
private $storage; protected $storage;
// todo event "listeners" instead of "callbacks" // todo event "listeners" instead of "callbacks"
/** @var callable[][] */ /** @var callable[][] */
public $callbacks = []; protected $callbacks = [];
public function __construct(Application $app, Contracts\StorageDriver $storage) public function __construct(Application $app, Contracts\StorageDriver $storage)
{ {
@ -50,7 +51,6 @@ class TenantManagerv2
return $this; return $this;
} }
// todo @throws
public function init(string $domain): self public function init(string $domain): self
{ {
$this->initializeTenancy($this->findByDomain($domain)); $this->initializeTenancy($this->findByDomain($domain));
@ -58,7 +58,6 @@ class TenantManagerv2
return $this; return $this;
} }
// todo @throws
public function initById(string $id): self public function initById(string $id): self
{ {
$this->initializeTenancy($this->find($id)); $this->initializeTenancy($this->find($id));
@ -66,13 +65,25 @@ class TenantManagerv2
return $this; return $this;
} }
// todo @throws /**
* Identify a tenant using id.
*
* @param string $id
* @return Tenant
* @throws TenantCouldNotBeIdentifiedException
*/
public function find(string $id): Tenant public function find(string $id): Tenant
{ {
return $this->storage->findById($id); return $this->storage->findById($id);
} }
// todo @throws /**
* Identify a tenant using id.
*
* @param string $id
* @return Tenant
* @throws TenantCouldNotBeIdentifiedException
*/
public function findByDomain(string $domain): Tenant public function findByDomain(string $domain): Tenant
{ {
return $this->storage->findByDomain($domain); return $this->storage->findByDomain($domain);