From 6d92ca5b56b4a4eb6bb5e1c2615884eed6b26082 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Tue, 17 Aug 2021 18:19:26 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Console/AbstractConsole.php | 2 +- System/Application.php | 20 +++++++++++++++++--- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/Console/AbstractConsole.php b/Console/AbstractConsole.php index aa17614f..a56f3235 100644 --- a/Console/AbstractConsole.php +++ b/Console/AbstractConsole.php @@ -57,7 +57,7 @@ abstract class AbstractConsole extends Component * @return mixed * @throws Exception */ - public function execCommand(Command $command): mixed + public function exec(Command $command): mixed { fire(new OnBeforeCommandExecute()); diff --git a/System/Application.php b/System/Application.php index c63c10e3..8a90f483 100644 --- a/System/Application.php +++ b/System/Application.php @@ -15,7 +15,6 @@ use Console\Console; use Console\ConsoleProviders; use Database\DatabasesProviders; use Exception; -use Http\Command; use Http\Context\Response; use Http\ServerProviders; use Kiri\Abstracts\BaseApplication; @@ -24,6 +23,7 @@ use Kiri\Abstracts\Input; use Kiri\Abstracts\Kernel; use Kiri\Crontab\CrontabProviders; use Kiri\Exception\NotFindClassException; +use Server\ResponseInterface; use stdClass; use Swoole\Timer; @@ -156,15 +156,29 @@ class Application extends BaseApplication // if (!($class instanceof Command)) { scan_directory(directory('app'), 'App'); // } - $data = di(Response::class)->getBuilder($manager->execCommand($class)); + $data = $this->getBuilder($manager->exec($class)); } catch (\Throwable $exception) { - $data = di(Response::class)->getBuilder(logger()->exception($exception)); + $data = $this->getBuilder(logger()->exception($exception)); } finally { print_r($data); Timer::clearAll(); } } + + /** + * @param $data + * @return Response|ResponseInterface + * @throws NotFindClassException + * @throws \ReflectionException + * @throws Exception + */ + private function getBuilder($data): Response|ResponseInterface + { + return di(Response::class)->getBuilder($data); + } + + /** * @param $className * @param null $abstracts