1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2026-02-05 18:34:04 +00:00

Resolve circular dependency

This commit is contained in:
Samuel Štancl 2019-10-27 18:56:43 +01:00
parent 540f1ee3d1
commit e872139c88
2 changed files with 15 additions and 3 deletions

View file

@ -28,14 +28,26 @@ class DatabaseManager
/** @var TenantManager */ /** @var TenantManager */
protected $tenancy; protected $tenancy;
public function __construct(Application $app, BaseDatabaseManager $database, TenantManager $tenantManager) public function __construct(Application $app, BaseDatabaseManager $database)
{ {
$this->app = $app; $this->app = $app;
$this->database = $database; $this->database = $database;
$this->tenancy = $tenantManager;
$this->originalDefaultConnectionName = $app['config']['database.default']; $this->originalDefaultConnectionName = $app['config']['database.default'];
} }
/**
* Set the TenantManager instance, used to dispatch tenancy events.
*
* @param TenantManager $tenantManager
* @return self
*/
public function withTenantManager(TenantManager $tenantManager): self
{
$this->tenancy = $tenantManager;
return $this;
}
/** /**
* Connect to a tenant's database. * Connect to a tenant's database.
* *

View file

@ -54,7 +54,7 @@ class TenantManager
$this->app = $app; $this->app = $app;
$this->storage = $storage; $this->storage = $storage;
$this->artisan = $artisan; $this->artisan = $artisan;
$this->database = $database; $this->database = $database->withTenantManager($this);
$this->bootstrapFeatures(); $this->bootstrapFeatures();
} }