diff --git a/src/Command/AllCommand.php b/src/Command/AllCommand.php index 3324c47b3..736367f71 100644 --- a/src/Command/AllCommand.php +++ b/src/Command/AllCommand.php @@ -27,6 +27,17 @@ */ class AllCommand extends BakeCommand { + /** + * All commands to call. + * + * @var string[] + */ + protected $commands = [ + ModelCommand::class, + ControllerCommand::class, + TemplateCommand::class, + ]; + /** * Gets the option parser instance and configures it. * @@ -83,13 +94,10 @@ public function execute(Arguments $args, ConsoleIo $io): ?int $tables = [$name]; } - $commands = [ - new ModelCommand(), - new ControllerCommand(), - new TemplateCommand(), - ]; - foreach ($tables as $table) { - foreach ($commands as $command) { + foreach ($this->commands as $commandName) { + /** @var \Cake\Command\Command $command */ + $command = new $commandName(); + foreach ($tables as $table) { $subArgs = new Arguments([$table], $args->getOptions(), ['name']); $command->execute($subArgs, $io); }