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:
parent
540f1ee3d1
commit
e872139c88
2 changed files with 15 additions and 3 deletions
|
|
@ -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.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -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();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue