mirror of
https://github.com/archtechx/tenancy.git
synced 2026-02-05 10:14:04 +00:00
refactor RootUrlBootstrapper
This commit is contained in:
parent
9f09c9e6dd
commit
4e126846f9
1 changed files with 17 additions and 10 deletions
|
|
@ -44,17 +44,24 @@ class RootUrlBootstrapper implements TenancyBootstrapper
|
|||
|
||||
public function bootstrap(Tenant $tenant): void
|
||||
{
|
||||
$shouldRunInTests = ! app()->runningUnitTests() || static::$rootUrlOverrideInTests;
|
||||
$shouldRun = $this->app->runningInConsole() && $shouldRunInTests && static::$rootUrlOverride;
|
||||
|
||||
if ($shouldRun) {
|
||||
$this->originalRootUrl = $this->app['url']->to('/');
|
||||
|
||||
$newRootUrl = (static::$rootUrlOverride)($tenant, $this->originalRootUrl);
|
||||
|
||||
$this->app['url']->forceRootUrl($newRootUrl);
|
||||
$this->config->set('app.url', $newRootUrl);
|
||||
if (static::$rootUrlOverride === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (! $this->app->runningInConsole()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (app()->runningUnitTests() && ! static::$rootUrlOverrideInTests) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->originalRootUrl = $this->app['url']->to('/');
|
||||
|
||||
$newRootUrl = (static::$rootUrlOverride)($tenant, $this->originalRootUrl);
|
||||
|
||||
$this->app['url']->forceRootUrl($newRootUrl);
|
||||
$this->config->set('app.url', $newRootUrl);
|
||||
}
|
||||
|
||||
public function revert(): void
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue