Skip to content

Commit

Permalink
Isolate the autoload run invokation.
Browse files Browse the repository at this point in the history
  • Loading branch information
JasperTey committed Nov 16, 2024
1 parent 9ab8b6f commit b8fa04c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
6 changes: 4 additions & 2 deletions src/LaravelDDDServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,15 +119,17 @@ protected function registerMigrations()

public function packageBooted()
{
Autoload::boot();

Autoload::run();

if ($this->app->runningInConsole() && method_exists($this, 'optimizes')) {
$this->optimizes(
optimize: 'ddd:optimize',
clear: 'ddd:clear',
key: 'laravel-ddd',
);
}

Autoload::boot();
}

public function packageRegistered()
Expand Down
5 changes: 2 additions & 3 deletions src/Support/AutoloadManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ public function boot()
->when(config('ddd.autoload.providers') === true, fn () => $this->handleProviders())
->when(app()->runningInConsole() && config('ddd.autoload.commands') === true, fn () => $this->handleCommands())
->when(config('ddd.autoload.policies') === true, fn () => $this->handlePolicies())
->when(config('ddd.autoload.factories') === true, fn () => $this->handleFactories())
->run();
->when(config('ddd.autoload.factories') === true, fn () => $this->handleFactories());

$this->booted = true;
}
Expand Down Expand Up @@ -152,7 +151,7 @@ protected function handleCommands()
return $this;
}

protected function run()
public function run()
{
if ($this->hasRun()) {
return $this;
Expand Down

0 comments on commit b8fa04c

Please sign in to comment.