modify plugin name
This commit is contained in:
+20
-17
@@ -6,6 +6,7 @@ namespace Gii;
|
|||||||
|
|
||||||
use Exception;
|
use Exception;
|
||||||
use Kiri;
|
use Kiri;
|
||||||
|
use Kiri\Di\LocalService;
|
||||||
use Kiri\Abstracts\Config;
|
use Kiri\Abstracts\Config;
|
||||||
use Kiri\Exception\ConfigException;
|
use Kiri\Exception\ConfigException;
|
||||||
use Symfony\Component\Console\Command\Command;
|
use Symfony\Component\Console\Command\Command;
|
||||||
@@ -26,15 +27,19 @@ class GiiCommand extends Command
|
|||||||
public string $description = './snowflake sw:gii make=model|controller|task|interceptor|limits|middleware name=xxxx';
|
public string $description = './snowflake sw:gii make=model|controller|task|interceptor|limits|middleware name=xxxx';
|
||||||
|
|
||||||
|
|
||||||
|
private LocalService $service;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
protected function configure()
|
protected function configure()
|
||||||
{
|
{
|
||||||
|
$this->service = Kiri::getDi()->get(LocalService::class);
|
||||||
$this->setName('sw:gii')
|
$this->setName('sw:gii')
|
||||||
->addOption('make','m', InputArgument::OPTIONAL)
|
->addOption('make', 'm', InputArgument::OPTIONAL)
|
||||||
->addOption('name','t', InputArgument::OPTIONAL)
|
->addOption('name', 't', InputArgument::OPTIONAL)
|
||||||
->addOption('databases','d', InputArgument::OPTIONAL)
|
->addOption('databases', 'd', InputArgument::OPTIONAL)
|
||||||
->setDescription('./snowflake sw:gii make=model|controller|task|interceptor|limits|middleware name=xxxx');
|
->setDescription('./snowflake sw:gii make=model|controller|task|interceptor|limits|middleware name=xxxx');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -43,34 +48,32 @@ class GiiCommand extends Command
|
|||||||
* @param InputInterface $input
|
* @param InputInterface $input
|
||||||
* @param OutputInterface $output
|
* @param OutputInterface $output
|
||||||
* @return int
|
* @return int
|
||||||
* @throws ConfigException
|
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function execute(InputInterface $input, OutputInterface $output): int
|
public function execute(InputInterface $input, OutputInterface $output): int
|
||||||
{
|
{
|
||||||
|
try {
|
||||||
/** @var Gii $gii */
|
/** @var Gii $gii */
|
||||||
$gii = Kiri::app()->get('gii');
|
$gii = $this->service->get('gii');
|
||||||
|
|
||||||
$connections = Kiri::app();
|
|
||||||
if (($db = $input->getOption('databases')) != null) {
|
if (($db = $input->getOption('databases')) != null) {
|
||||||
$gii->run($connections->get($db), $input);
|
$gii->run($this->service->get($db), $input);
|
||||||
return 1;
|
} else {
|
||||||
}
|
|
||||||
|
|
||||||
$action = $input->getOption('make');
|
$action = $input->getOption('make');
|
||||||
if (!in_array($action, ['model', 'controller'])) {
|
if (!in_array($action, ['model', 'controller'])) {
|
||||||
$gii->run(null, $input);
|
$gii->run(null, $input);
|
||||||
return 1;
|
} else {
|
||||||
}
|
|
||||||
|
|
||||||
$array = [];
|
$array = [];
|
||||||
foreach (Config::get('databases.connections') as $key => $connection) {
|
foreach (Config::get('databases.connections') as $key => $connection) {
|
||||||
$array[$key] = $gii->run($connections->get($key), $input);
|
$array[$key] = $gii->run($this->service->get($key), $input);
|
||||||
}
|
}
|
||||||
|
|
||||||
$output->writeln(json_encode($array, JSON_UNESCAPED_UNICODE));
|
$output->writeln(json_encode($array, JSON_UNESCAPED_UNICODE));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (\Throwable $throwable) {
|
||||||
|
$output->writeln($throwable->getMessage());
|
||||||
|
} finally {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+11
-10
@@ -5,10 +5,11 @@ declare(strict_types=1);
|
|||||||
namespace Gii;
|
namespace Gii;
|
||||||
|
|
||||||
|
|
||||||
use Exception;
|
|
||||||
use Kiri;
|
|
||||||
use Kiri\Abstracts\Providers;
|
use Kiri\Abstracts\Providers;
|
||||||
use Kiri\Application;
|
use Kiri\Di\LocalService;
|
||||||
|
use Psr\Container\ContainerExceptionInterface;
|
||||||
|
use Psr\Container\NotFoundExceptionInterface;
|
||||||
|
use Symfony\Component\Console\Application;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class DatabasesProviders
|
* Class DatabasesProviders
|
||||||
@@ -19,16 +20,16 @@ class GiiProviders extends Providers
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Application $application
|
* @param LocalService $application
|
||||||
* @throws Exception
|
* @return void
|
||||||
|
* @throws ContainerExceptionInterface
|
||||||
|
* @throws NotFoundExceptionInterface
|
||||||
*/
|
*/
|
||||||
public function onImport(Application $application)
|
public function onImport(LocalService $application): void
|
||||||
{
|
{
|
||||||
$application->set('gii', ['class' => Gii::class]);
|
$application->set('gii', ['class' => Gii::class]);
|
||||||
|
|
||||||
$container = Kiri::getDi();
|
$console = $this->container->get(Application::class);
|
||||||
|
$console->add($this->container->get(GiiCommand::class));
|
||||||
$console = $container->get(\Symfony\Component\Console\Application::class);
|
|
||||||
$console->add($container->get(GiiCommand::class));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user