Skip to content

Commit

Permalink
fix differently
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonvarga committed Oct 1, 2024
1 parent 81d3d7b commit b730e62
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/Providers/AddonServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ protected function bootPolicies()

protected function bootCommands()
{
if ($this->app->isBooted() && $this->app->runningInConsole()) {
if ($this->app->runningInConsole()) {
$commands = collect($this->commands)
->merge($this->autoloadFilesFromFolder('Commands', Command::class))
->merge($this->autoloadFilesFromFolder('Console/Commands', Command::class))
Expand Down Expand Up @@ -704,7 +704,15 @@ protected function bootFieldsets()

protected function autoloadFilesFromFolder($folder, $requiredClass)
{
$addon = $this->getAddon();
try {
$addon = $this->getAddon();
} catch (NotBootedException $e) {
// This would be thrown if a developer has tried to call a method
// that triggers autoloading before Statamic has booted. Perhaps
// they have placed it in the boot method instead of bootAddon.
return [];
}

$path = $addon->directory().$addon->autoload().'/'.$folder;

if (! $this->app['files']->exists($path)) {
Expand Down

0 comments on commit b730e62

Please sign in to comment.