Files
kiri-core/Gii/Command.php
T

49 lines
887 B
PHP
Raw Normal View History

2020-09-08 15:59:15 +08:00
<?php
2020-10-30 01:07:28 +08:00
declare(strict_types=1);
2020-09-08 15:59:15 +08:00
namespace Gii;
use Exception;
2021-01-19 19:04:21 +08:00
use Snowflake\Abstracts\Config;
2020-09-08 15:59:15 +08:00
use Snowflake\Abstracts\Input;
use Snowflake\Exception\ConfigException;
use Snowflake\Snowflake;
/**
* Class Command
* @package HttpServer
*/
class Command extends \Console\Command
{
2020-10-30 01:07:28 +08:00
public string $command = 'sw:gii';
2020-09-08 15:59:15 +08:00
2020-10-30 01:07:28 +08:00
public string $description = 'server start|stop|reload|restart';
2020-09-08 15:59:15 +08:00
/**
* @param Input $dtl
* @return array
* @throws Exception
*/
2020-12-17 14:09:14 +08:00
public function onHandler(Input $dtl): array
2020-09-08 15:59:15 +08:00
{
/** @var Gii $gii */
$gii = Snowflake::app()->get('gii');
2021-01-19 19:04:21 +08:00
$connections = Snowflake::app()->db;
if ($dtl->exists('databases')) {
return $gii->run($connections->get($dtl->get('databases')), $dtl);
}
$array = [];
foreach (Config::get('databases') as $key => $connection) {
$array[$key] = $gii->run($connections->get($key), $dtl);
}
return $array;
2020-09-08 15:59:15 +08:00
}
}