This commit is contained in:
2021-08-17 18:19:26 +08:00
parent b441c07ef5
commit 6d92ca5b56
2 changed files with 18 additions and 4 deletions
+1 -1
View File
@@ -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());
+17 -3
View File
@@ -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