| 1234567891011121314151617181920212223242526272829303132 |
- <?php
- declare(strict_types=1);
- namespace SixShop\Core\Service;
- use Closure;
- use think\exception\ClassNotFoundException;
- use function SixShop\Core\extension_name_list;
- readonly class CommandService
- {
- public function __construct(private AutoloadService $autoloadService)
- {
- }
- public function init(Closure $closure): void
- {
- $commands = [];
- foreach (extension_name_list() as $extensionName) {
- try {
- $extension = $this->autoloadService->getExtension($extensionName);
- } catch (ClassNotFoundException $_) {
- continue;
- }
- if (!$extension->available()) {
- continue;
- }
- $commands += $extension->getCommands();
- }
- $closure($commands);
- }
- }
|