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\GeneratorException; |
||
| 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 | * Generate Module Structure |
||
| 16 | * |
||
| 17 | * @package Bluzman\Command\Generate |
||
| 18 | */ |
||
| 19 | class ModuleCommand 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:module') |
||
| 29 | 15 | // the short description shown while running "php bin/bluzman list" |
|
| 30 | ->setDescription('Generate a new module') |
||
| 31 | // the full command description shown when running the command with |
||
| 32 | 15 | // the "--help" option |
|
| 33 | ->setHelp('This command allows you to generate a module structure') |
||
| 34 | ; |
||
| 35 | 15 | ||
| 36 | 15 | $this->addModuleArgument(); |
|
| 37 | 15 | $this->addForceOption(); |
|
| 38 | } |
||
| 39 | |||
| 40 | /** |
||
| 41 | * @param InputInterface $input |
||
| 42 | * @param OutputInterface $output |
||
| 43 | * @return int |
||
| 44 | 2 | */ |
|
| 45 | protected function execute(InputInterface $input, OutputInterface $output) |
||
| 46 | 2 | { |
|
| 47 | $this->write('Running <info>generate:module</info> command'); |
||
| 48 | try { |
||
| 49 | 2 | // validate |
|
| 50 | $this->validateModuleArgument(); |
||
| 51 | |||
| 52 | 1 | // create main folder and subfolders |
|
| 53 | $this->generate($input, $output); |
||
| 54 | |||
| 55 | 1 | // verify it |
|
| 56 | 1 | $this->verify($input, $output); |
|
| 57 | 1 | return 0; |
|
| 58 | } catch (\Exception $e) { |
||
| 59 | 2 | $this->error("ERROR: {$e->getMessage()}"); |
|
| 60 | return $e->getCode(); |
||
| 61 | } |
||
| 62 | } |
||
| 63 | |||
| 64 | /** |
||
| 65 | * @param InputInterface $input |
||
| 66 | 1 | * @param OutputInterface $output |
|
| 67 | * @return void |
||
| 68 | 1 | */ |
|
| 69 | 1 | protected function generate(InputInterface $input, OutputInterface $output) |
|
| 70 | 1 | { |
|
| 71 | $path = $this->getApplication()->getModulePath($input->getArgument('module')); |
||
| 72 | 1 | $this->createSubFolders( |
|
| 73 | $path, |
||
| 74 | [ |
||
| 75 | 'controllers', |
||
| 76 | 1 | 'views' |
|
| 77 | ] |
||
| 78 | ); |
||
| 79 | } |
||
| 80 | |||
| 81 | /** |
||
| 82 | 1 | * @param string $path |
|
| 83 | * @param string[] $subFolders |
||
| 84 | 1 | */ |
|
| 85 | 1 | protected function createSubFolders($path, array $subFolders = []) |
|
| 86 | { |
||
| 87 | if (!$this->getFs()->exists($path)) { |
||
| 88 | 1 | $this->getFs()->mkdir($path); |
|
| 89 | 1 | } |
|
| 90 | 1 | ||
| 91 | foreach ($subFolders as $subFolderName) { |
||
| 92 | $subFolderPath = $path . DIRECTORY_SEPARATOR . $subFolderName; |
||
| 93 | 1 | if ($this->getFs()->exists($subFolderPath)) { |
|
| 94 | 1 | $this->comment(" |> Directory <info>$subFolderPath</info> already exists"); |
|
| 95 | } else { |
||
| 96 | $this->getFs()->mkdir($subFolderPath, 0755); |
||
| 97 | 1 | $this->getFs()->touch([$subFolderPath . DIRECTORY_SEPARATOR . '.keep']); |
|
| 98 | } |
||
| 99 | } |
||
| 100 | } |
||
| 101 | |||
| 102 | /** |
||
| 103 | * @param InputInterface $input |
||
| 104 | * @param OutputInterface $output |
||
| 105 | 1 | * @return void |
|
| 106 | * @throws GeneratorException |
||
| 107 | 1 | */ |
|
| 108 | 1 | public function verify(InputInterface $input, OutputInterface $output): void |
|
| 109 | { |
||
| 110 | $module = $input->getArgument('module'); |
||
| 111 | 1 | $modulePath = $this->getApplication()->getModulePath($module); |
|
| 112 | 1 | ||
| 113 | 1 | $paths = [ |
|
| 114 | $modulePath, |
||
| 115 | $modulePath . DS . 'controllers', |
||
|
0 ignored issues
–
show
|
|||
| 116 | 1 | $modulePath . DS . 'views' |
|
| 117 | 1 | ]; |
|
| 118 | 1 | ||
| 119 | foreach ($paths as $path) { |
||
| 120 | if (!$this->getFs()->exists($path)) { |
||
| 121 | throw new GeneratorException("Directory `$path` is not exists"); |
||
| 122 | 1 | } |
|
| 123 | 1 | } |
|
| 124 | |||
| 125 | $this->write(" |> Module <info>$module</info> has been successfully created."); |
||
| 126 | } |
||
| 127 | } |
||
| 128 |
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