This commit is contained in:
xl
2024-09-03 14:47:29 +08:00
parent 8d5e8c4b3f
commit d84ddd23c8
2 changed files with 9 additions and 7 deletions
+5 -5
View File
@@ -121,8 +121,8 @@ class Gii
$this->tableName = $input->getOption('table'); $this->tableName = $input->getOption('table');
} }
return match ($make) { return match ($make) {
'controller' => $this->getTable(1, 0), 'controller' => $this->getTable($input, 1, 0),
'model' => $this->getTable(0, 1), 'model' => $this->getTable($input, 0, 1),
default => [], default => [],
}; };
} }
@@ -135,7 +135,7 @@ class Gii
* *
* @throws Exception * @throws Exception
*/ */
private function getTable($controller, $model): array private function getTable($input, $controller, $model): array
{ {
$tables = $this->getFields($this->getTables()); $tables = $this->getFields($this->getTables());
if (empty($tables)) { if (empty($tables)) {
@@ -146,10 +146,10 @@ class Gii
foreach ($tables as $key => $val) { foreach ($tables as $key => $val) {
$data = $this->createModelFile($key, $val); $data = $this->createModelFile($key, $val);
if ($controller == 1) { if ($controller == 1) {
$fileList[] = $this->generateController($data); $fileList[] = $this->generateController($input, $data);
} }
if ($model == 1) { if ($model == 1) {
$fileList[] = $this->generateModel($data); $fileList[] = $this->generateModel($input, $data);
} }
} }
return $fileList; return $fileList;
+2
View File
@@ -10,6 +10,7 @@ use Kiri;
use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Output\OutputInterface;
/** /**
@@ -34,6 +35,7 @@ class GiiCommand extends Command
->addOption('make', 'm', InputArgument::OPTIONAL) ->addOption('make', 'm', InputArgument::OPTIONAL)
->addOption('table', 't', InputArgument::OPTIONAL) ->addOption('table', 't', InputArgument::OPTIONAL)
->addOption('database', 'd', InputArgument::OPTIONAL) ->addOption('database', 'd', InputArgument::OPTIONAL)
->addOption('all-table', null, InputOption::VALUE_NONE, 'is run daemonize')
->setDescription('php kiri.php sw:gii --table u_user --database users --make model'); ->setDescription('php kiri.php sw:gii --table u_user --database users --make model');
} }