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

refactor RootUrlBootstrapper

This commit is contained in:
Samuel Štancl 2024-08-29 22:31:08 +02:00
parent 9f09c9e6dd
commit 4e126846f9

View file

@ -44,17 +44,24 @@ class RootUrlBootstrapper implements TenancyBootstrapper
public function bootstrap(Tenant $tenant): void public function bootstrap(Tenant $tenant): void
{ {
$shouldRunInTests = ! app()->runningUnitTests() || static::$rootUrlOverrideInTests; if (static::$rootUrlOverride === null) {
$shouldRun = $this->app->runningInConsole() && $shouldRunInTests && static::$rootUrlOverride; return;
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 (! $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 public function revert(): void