|
|
@@ -5,8 +5,10 @@ namespace SixShop\Core\Service;
|
|
|
|
|
|
use Composer\InstalledVersions;
|
|
|
use Composer\Json\JsonFile;
|
|
|
+use getallheaders\Tests\GetAllHeadersTest;
|
|
|
use ReflectionException;
|
|
|
use Seld\JsonLint\ParsingException;
|
|
|
+use SixShop\Core\Contracts\ExtensionInterface;
|
|
|
use SixShop\Core\Exception\ExceptionHandle;
|
|
|
use SixShop\Core\Plugin;
|
|
|
use SixShop\Core\Request;
|
|
|
@@ -28,6 +30,12 @@ class CoreService extends Service
|
|
|
return self::$extensionComposerMap;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @param array<string, ExtensionInterface> $bootedExtensionMap
|
|
|
+ * @var array
|
|
|
+ */
|
|
|
+ public private(set) array $bootedExtensionMap = [];
|
|
|
+
|
|
|
/**
|
|
|
* @throws ParsingException
|
|
|
*/
|
|
|
@@ -93,15 +101,20 @@ class CoreService extends Service
|
|
|
}
|
|
|
$extension->boot();
|
|
|
$this->app->event->trigger('extension.boot', $extension);
|
|
|
+ $this->bootedExtensionMap[$moduleName] = $extension;
|
|
|
}
|
|
|
- $this->app->make(HookAttributeService::class)->init();
|
|
|
+ $this->app->make(HookAttributeService::class)->init($this->bootedExtensionMap);
|
|
|
$this->app->event->trigger('hook_init', $this->app);
|
|
|
- $this->app->event->listen(HttpRun::class, function () {
|
|
|
- $this->registerRoutes($this->app->make(RegisterRouteService::class)->init());
|
|
|
- });
|
|
|
-
|
|
|
- $this->app->make(CommandService::class)->init(function ($commands) {
|
|
|
- $this->commands($commands);
|
|
|
- });
|
|
|
+ if ($this->app->runningInConsole()) {
|
|
|
+ $this->app->make(CommandService::class)->init(function ($commands) {
|
|
|
+ $this->commands($commands);
|
|
|
+ }, $this->bootedExtensionMap);
|
|
|
+ } else {
|
|
|
+ $this->app->event->listen(HttpRun::class, function () {
|
|
|
+ $this->registerRoutes(function () {
|
|
|
+ $this->app->make(RegisterRouteService::class)->init($this->bootedExtensionMap);
|
|
|
+ });
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
}
|