Skip to content

Commit

Permalink
refactor: Boot service override _AFTER_ the application has booted
Browse files Browse the repository at this point in the history
Remove the manual booting of service overrides from the SproutServiceProvider::boot() method and add to the Application::booted() lifecycle event
  • Loading branch information
ollieread committed Nov 23, 2024
1 parent 52844e3 commit febbe05
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/SproutServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public function register(): void
$this->registerManagers();
$this->registerMiddleware();
$this->registerRouteMixin();
$this->registerServiceOverrideBooting();
}

private function registerSprout(): void
Expand Down Expand Up @@ -78,13 +79,17 @@ protected function registerRouteMixin(): void
Router::mixin(new RouterMethods());
}

protected function registerServiceOverrideBooting(): void
{
$this->app->booted($this->sprout->bootOverrides(...));
}

public function boot(): void
{
$this->publishConfig();
$this->registerServiceOverrides();
$this->registerEventListeners();
$this->registerTenancyBootstrappers();
$this->bootServiceOverrides();
}

private function publishConfig(): void
Expand Down Expand Up @@ -128,9 +133,4 @@ private function registerTenancyBootstrappers(): void
$events->listen(CurrentTenantChanged::class, $bootstrapper);
}
}

private function bootServiceOverrides(): void
{
$this->sprout->bootOverrides();
}
}

0 comments on commit febbe05

Please sign in to comment.