56 ->setName(
'make:controller')
57 ->setDescription(
'Make empty controller file')
58 ->addArgument(
'name', InputArgument::REQUIRED,
'controller name')
59 ->addArgument(
'module', InputArgument::OPTIONAL,
'module id')
60 ->addOption(
'namespace',
'ns', InputOption::VALUE_REQUIRED,
'custom namespace')
61 ->addOption(
'psr4',
null, InputOption::VALUE_NEGATABLE,
'generate file path in PSR4 / camelCase style, ex: `module/lib/My/ClassName.php`',
true)
62 ->addOption(
'root',
null, InputOption::VALUE_REQUIRED,
'root folder for generate. Defaults server document root')
63 ->addOption(
'show',
null, InputOption::VALUE_NONE,
'outputs to console, without saving it. It can be used to save to an arbitrary location when using the `>` operator.')
64 ->addOption(
'actions',
null, InputArgument::OPTIONAL,
'generate given actions in controller. Use alias "crud" for CRUD actions')
65 ->addOption(
'alias',
null, InputArgument::OPTIONAL,
'controller\'s namespace alias from .settings.php')
69 protected function execute(InputInterface $input, OutputInterface
$output): int
71 $name = $input->getArgument(
'name');
72 if (!is_string(
$name))
74 throw new InvalidArgumentException(
'Controller name must be string');
79 moduleId: $input->getArgument(
'module'),
80 namespace: $input->getOption(
'namespace'),
81 rootFolder: $input->getOption(
'root'),
82 psr4: $input->getOption(
'psr4') ===
true,
83 actions: $this->resolveActions($input),
84 alias: $input->getOption(
'alias'),
87 if ($input->getOption(
'show') ===
true)
89 $output->write($this->service->generateContent($dto));
94 $this->service->generateFile($dto);