This commit is contained in:
2020-11-06 15:55:17 +08:00
parent 4dc3ff8e6f
commit 0171e39c70
2 changed files with 29 additions and 0 deletions
+15
View File
@@ -0,0 +1,15 @@
<?php
namespace Snowflake\Abstracts;
interface Kernel
{
/**
* @return array
*/
public function getCommands(): array;
}
+14
View File
@@ -19,6 +19,7 @@ use Queue\QueueProviders;
use Snowflake\Abstracts\BaseApplication;
use Snowflake\Abstracts\Config;
use Snowflake\Abstracts\Input;
use Snowflake\Abstracts\Kernel;
use Snowflake\Exception\NotFindClassException;
use Snowflake\Exception\ConfigException;
use Swoole\Coroutine;
@@ -73,6 +74,19 @@ class Application extends BaseApplication
}
/**
* @param $kernel
* @return $this
*/
public function commands(Kernel $kernel)
{
foreach ($kernel->getCommands() as $command) {
$this->register($command);
}
return $this;
}
/**
* @param string $command
* @throws