bluzphp /
bluzman
| 1 | <?php |
||
| 2 | |||
| 3 | /** |
||
| 4 | * @copyright Bluz PHP Team |
||
| 5 | * @link https://github.com/bluzphp/bluzman |
||
| 6 | */ |
||
| 7 | |||
| 8 | namespace Bluzman\Command\Generate; |
||
| 9 | |||
| 10 | use Bluzman\Generator; |
||
| 11 | use Symfony\Component\Console\Input\InputInterface; |
||
|
0 ignored issues
–
show
|
|||
| 12 | use Symfony\Component\Console\Output\OutputInterface; |
||
|
0 ignored issues
–
show
The type
Symfony\Component\Console\Output\OutputInterface was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 13 | |||
| 14 | /** |
||
| 15 | * ControllerCommand |
||
| 16 | * |
||
| 17 | * @package Bluzman\Command\Generate |
||
| 18 | */ |
||
| 19 | class ControllerCommand extends AbstractGenerateCommand |
||
| 20 | { |
||
| 21 | /** |
||
| 22 | * Command configuration |
||
| 23 | 15 | */ |
|
| 24 | protected function configure() |
||
| 25 | { |
||
| 26 | $this |
||
| 27 | 15 | // the name of the command (the part after "bin/bluzman") |
|
| 28 | ->setName('generate:controller') |
||
| 29 | 15 | // the short description shown while running "php bin/bluzman list" |
|
| 30 | ->setDescription('Generate a new controller') |
||
| 31 | // the full command description shown when running the command with |
||
| 32 | 15 | // the "--help" option |
|
| 33 | ->setHelp('This command allows you to generate controller files') |
||
| 34 | ; |
||
| 35 | 15 | ||
| 36 | 15 | $this->addModuleArgument(); |
|
| 37 | 15 | $this->addControllerArgument(); |
|
| 38 | 15 | $this->addForceOption(); |
|
| 39 | } |
||
| 40 | |||
| 41 | /** |
||
| 42 | * @param InputInterface $input |
||
| 43 | * @param OutputInterface $output |
||
| 44 | * @return int |
||
| 45 | 1 | */ |
|
| 46 | protected function execute(InputInterface $input, OutputInterface $output) |
||
| 47 | 1 | { |
|
| 48 | $this->write('Running <info>generate:controller</info> command'); |
||
| 49 | try { |
||
| 50 | 1 | // validate |
|
| 51 | 1 | $this->validateModuleArgument(); |
|
| 52 | $this->validateControllerArgument(); |
||
| 53 | |||
| 54 | 1 | // generate directories and files |
|
| 55 | $this->generate($input, $output); |
||
| 56 | |||
| 57 | 1 | // verify it |
|
| 58 | $this->verify($input, $output); |
||
| 59 | return 0; |
||
| 60 | } catch (\Exception $e) { |
||
| 61 | 1 | $this->error("ERROR: {$e->getMessage()}"); |
|
| 62 | return $e->getCode(); |
||
| 63 | } |
||
| 64 | } |
||
| 65 | |||
| 66 | /** |
||
| 67 | * @param InputInterface $input |
||
| 68 | 1 | * @param OutputInterface $output |
|
| 69 | * @return void |
||
| 70 | 1 | */ |
|
| 71 | 1 | protected function generate(InputInterface $input, OutputInterface $output): void |
|
| 72 | { |
||
| 73 | 1 | $module = $input->getArgument('module'); |
|
| 74 | 1 | $controller = $input->getArgument('controller'); |
|
| 75 | |||
| 76 | 1 | $controllerFile = $this->getControllerPath($module, $controller); |
|
| 77 | 1 | $this->generateFile('ControllerTemplate', $controllerFile); |
|
| 78 | 1 | ||
| 79 | $viewFile = $this->getViewPath($module, $controller); |
||
| 80 | $this->generateFile('ViewTemplate', $viewFile, ['name' => $controller]); |
||
| 81 | } |
||
| 82 | |||
| 83 | /** |
||
| 84 | * @param InputInterface $input |
||
| 85 | * @param OutputInterface $output |
||
| 86 | 1 | * @return void |
|
| 87 | * @throws \Bluzman\Generator\GeneratorException |
||
| 88 | 1 | */ |
|
| 89 | 1 | public function verify(InputInterface $input, OutputInterface $output): void |
|
| 90 | { |
||
| 91 | 1 | $module = $input->getArgument('module'); |
|
| 92 | $controller = $input->getArgument('controller'); |
||
| 93 | |||
| 94 | 1 | $modulePath = $this->getApplication()->getModulePath($module); |
|
| 95 | 1 | ||
| 96 | 1 | $paths = [ |
|
| 97 | 1 | $modulePath, |
|
| 98 | 1 | $modulePath . DS . 'controllers', |
|
|
0 ignored issues
–
show
|
|||
| 99 | $modulePath . DS . 'controllers' . DS . $controller . '.php', |
||
| 100 | $modulePath . DS . 'views', |
||
| 101 | $modulePath . DS . 'views' . DS . $controller . '.phtml', |
||
| 102 | 1 | ||
| 103 | 1 | ]; |
|
| 104 | 1 | ||
| 105 | foreach ($paths as $path) { |
||
| 106 | if (!$this->getFs()->exists($path)) { |
||
| 107 | throw new Generator\GeneratorException("File or directory `$path` is not exists"); |
||
| 108 | 1 | } |
|
| 109 | 1 | } |
|
| 110 | 1 | ||
| 111 | $this->write( |
||
| 112 | 1 | " |> Controller <info>{$controller}</info> has been successfully created " . |
|
| 113 | "in the module <info>{$module}</info>." |
||
| 114 | ); |
||
| 115 | } |
||
| 116 | } |
||
| 117 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths