From cf39cb2eb3377c1512beeb9e80ad293b5570586c Mon Sep 17 00:00:00 2001 From: Jasper Tey Date: Fri, 15 Nov 2024 22:39:12 -0500 Subject: [PATCH] Allow null for console environments. --- src/Commands/OptimizeCommand.php | 6 +++--- src/Support/AutoloadManager.php | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Commands/OptimizeCommand.php b/src/Commands/OptimizeCommand.php index b36f7cd..58b2245 100644 --- a/src/Commands/OptimizeCommand.php +++ b/src/Commands/OptimizeCommand.php @@ -3,7 +3,7 @@ namespace Lunarstorm\LaravelDDD\Commands; use Illuminate\Console\Command; -use Lunarstorm\LaravelDDD\Facades\DDD; +use Lunarstorm\LaravelDDD\Facades\Autoload; use Lunarstorm\LaravelDDD\Support\DomainMigration; class OptimizeCommand extends Command @@ -24,8 +24,8 @@ protected function configure() public function handle() { $this->components->info('Caching DDD providers, commands, migration paths.'); - $this->components->task('domain providers', fn () => DDD::autoloader()->cacheProviders()); - $this->components->task('domain commands', fn () => DDD::autoloader()->cacheCommands()); + $this->components->task('domain providers', fn () => Autoload::cacheProviders()); + $this->components->task('domain commands', fn () => Autoload::cacheCommands()); $this->components->task('domain migration paths', fn () => DomainMigration::cachePaths()); $this->newLine(); } diff --git a/src/Support/AutoloadManager.php b/src/Support/AutoloadManager.php index f35351d..25a7074 100644 --- a/src/Support/AutoloadManager.php +++ b/src/Support/AutoloadManager.php @@ -48,9 +48,9 @@ class AutoloadManager * @param \Illuminate\Contracts\Foundation\Application $app * @return void */ - public function __construct($app) + public function __construct($app = null) { - $this->app = $app; + $this->app = $app ?? Container::getInstance()->make(Application::class); $this->appNamespace = $this->app->getNamespace(); }