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\Input\InputArgument; |
||
| 11 | use Bluzman\Input\InputException; |
||
| 12 | use Bluzman\Generator; |
||
| 13 | use Symfony\Component\Console\Input\InputInterface; |
||
|
0 ignored issues
–
show
|
|||
| 14 | 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...
|
|||
| 15 | |||
| 16 | /** |
||
| 17 | * ModelCommand |
||
| 18 | * |
||
| 19 | * @package Bluzman\Command\Generate |
||
| 20 | */ |
||
| 21 | class GridCommand extends AbstractGenerateCommand |
||
| 22 | { |
||
| 23 | /** |
||
| 24 | * Command configuration |
||
| 25 | 15 | */ |
|
| 26 | protected function configure() |
||
| 27 | { |
||
| 28 | $this |
||
| 29 | 15 | // the name of the command (the part after "bin/bluzman") |
|
| 30 | ->setName('generate:grid') |
||
| 31 | 15 | // the short description shown while running "php bin/bluzman list" |
|
| 32 | ->setDescription('Generate a GRID for model') |
||
| 33 | // the full command description shown when running the command with |
||
| 34 | 15 | // the "--help" option |
|
| 35 | ->setHelp('This command allows you to generate GRID files') |
||
| 36 | ; |
||
| 37 | 15 | ||
| 38 | 15 | $this->addModelArgument(); |
|
| 39 | 15 | $this->addModuleArgument(InputArgument::OPTIONAL); |
|
| 40 | 15 | $this->addForceOption(); |
|
| 41 | } |
||
| 42 | |||
| 43 | /** |
||
| 44 | * @param InputInterface $input |
||
| 45 | * @param OutputInterface $output |
||
| 46 | * |
||
| 47 | * @return int |
||
| 48 | * @throws \Bluzman\Generator\GeneratorException |
||
| 49 | 3 | */ |
|
| 50 | protected function execute(InputInterface $input, OutputInterface $output) |
||
| 51 | 3 | { |
|
| 52 | $this->write('Running <info>generate:grid</info> command'); |
||
| 53 | try { |
||
| 54 | 3 | // validate |
|
| 55 | 1 | $this->validateModelArgument(); |
|
| 56 | $this->validateModuleArgument(); |
||
| 57 | |||
| 58 | 1 | // generate directories and files |
|
| 59 | $this->generate($input, $output); |
||
| 60 | |||
| 61 | 1 | // verify files |
|
| 62 | 2 | $this->verify($input, $output); |
|
| 63 | 2 | return 0; |
|
| 64 | } catch (InputException $e) { |
||
| 65 | 3 | $this->error("ERROR: {$e->getMessage()}"); |
|
| 66 | return $e->getCode(); |
||
| 67 | } |
||
| 68 | } |
||
| 69 | |||
| 70 | /** |
||
| 71 | * @param InputInterface $input |
||
| 72 | * @param OutputInterface $output |
||
| 73 | * |
||
| 74 | 1 | * @return void |
|
| 75 | * @throws Generator\GeneratorException |
||
| 76 | 1 | */ |
|
| 77 | 1 | protected function generate(InputInterface $input, OutputInterface $output): void |
|
| 78 | { |
||
| 79 | $model = ucfirst($input->getArgument('model')); |
||
| 80 | $module = $input->getArgument('module'); |
||
| 81 | 1 | ||
| 82 | 1 | // template data |
|
| 83 | $data = [ |
||
| 84 | 'model' => $model, |
||
| 85 | 1 | 'module' => $module |
|
| 86 | ]; |
||
| 87 | |||
| 88 | if ($module) { |
||
| 89 | // controller and view generators required the `Model\Table` class |
||
| 90 | // validator is present on previous step |
||
| 91 | $data['columns'] = $this->getTableInstance($model)::getMeta(); |
||
| 92 | 1 | } |
|
| 93 | |||
| 94 | 1 | // generate GRID class |
|
| 95 | 1 | $this->write(" |> Generate Grid class <info>$model\\Grid</info>"); |
|
| 96 | |||
| 97 | 1 | $gridFile = $this->getApplication()->getModelPath($model) . DS . 'Grid.php'; |
|
|
0 ignored issues
–
show
|
|||
| 98 | $this->generateFile('GridTemplate', $gridFile, $data); |
||
| 99 | |||
| 100 | if ($module) { |
||
| 101 | $this->write(" |> Generate Grid controller <info>$module/controllers/grid.php</info>"); |
||
| 102 | |||
| 103 | $controllerFile = $this->getControllerPath($module, 'grid'); |
||
| 104 | $this->generateFile('GridControllerTemplate', $controllerFile, $data); |
||
| 105 | |||
| 106 | $this->write(" |> Generate Grid view <info>$module/views/grid.phtml</info>"); |
||
| 107 | |||
| 108 | 1 | $viewFile = $this->getViewPath($module, 'grid'); |
|
| 109 | $this->generateFile('GridViewTemplate', $viewFile, $data); |
||
| 110 | } |
||
| 111 | } |
||
| 112 | |||
| 113 | /** |
||
| 114 | * @param InputInterface $input |
||
| 115 | * @param OutputInterface $output |
||
| 116 | 1 | * @return void |
|
| 117 | * @throws \Bluzman\Generator\GeneratorException |
||
| 118 | 1 | */ |
|
| 119 | 1 | public function verify(InputInterface $input, OutputInterface $output): void |
|
| 120 | { |
||
| 121 | 1 | $model = $input->getArgument('model'); |
|
| 122 | $module = $input->getArgument('module'); |
||
| 123 | |||
| 124 | 1 | $modelPath = $this->getApplication()->getModelPath($model); |
|
| 125 | |||
| 126 | $paths = [ |
||
| 127 | 1 | $modelPath . DS . 'Grid.php', |
|
|
0 ignored issues
–
show
|
|||
| 128 | 1 | ]; |
|
| 129 | 1 | ||
| 130 | foreach ($paths as $path) { |
||
| 131 | if (!$this->getFs()->exists($path)) { |
||
| 132 | throw new Generator\GeneratorException("File `$path` is not exists"); |
||
| 133 | 1 | } |
|
| 134 | } |
||
| 135 | 1 | ||
| 136 | $this->write(" |> GRID for <info>{$model}</info> has been successfully created."); |
||
| 137 | |||
| 138 | if ($module) { |
||
| 139 | $this->write( |
||
| 140 | " |> <options=bold>Open page <info>/acl</info> in your browser " . |
||
| 141 | 1 | "and set permission <info>Management</info> for <info>{$module}</info> module</>" |
|
| 142 | ); |
||
| 143 | } |
||
| 144 | } |
||
| 145 | } |
||
| 146 |
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