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\ArrayInput; |
||
|
0 ignored issues
–
show
|
|||
| 12 | use Symfony\Component\Console\Input\InputInterface; |
||
|
0 ignored issues
–
show
The type
Symfony\Component\Console\Input\InputInterface 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 | 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...
|
|||
| 14 | |||
| 15 | /** |
||
| 16 | * Generate Module Structure |
||
| 17 | * |
||
| 18 | * @package Bluzman\Command\Generate |
||
| 19 | */ |
||
| 20 | class ScaffoldCommand extends AbstractGenerateCommand |
||
| 21 | { |
||
| 22 | /** |
||
| 23 | * Command configuration |
||
| 24 | 15 | */ |
|
| 25 | protected function configure() |
||
| 26 | { |
||
| 27 | $this |
||
| 28 | 15 | // the name of the command (the part after "bin/bluzman") |
|
| 29 | ->setName('generate:scaffold') |
||
| 30 | 15 | // the short description shown while running "php bin/bluzman list" |
|
| 31 | ->setDescription('Generate a new model and module with crud and grid') |
||
| 32 | // the full command description shown when running the command with |
||
| 33 | 15 | // the "--help" option |
|
| 34 | ->setHelp('This command allows you to generate a scaffolding') |
||
| 35 | ; |
||
| 36 | 15 | ||
| 37 | 15 | $this->addModelArgument(); |
|
| 38 | 15 | $this->addTableArgument(); |
|
| 39 | 15 | $this->addModuleArgument(); |
|
| 40 | 15 | $this->addForceOption(); |
|
| 41 | } |
||
| 42 | |||
| 43 | /** |
||
| 44 | * {@inheritdoc} |
||
| 45 | 1 | */ |
|
| 46 | protected function execute(InputInterface $input, OutputInterface $output) |
||
| 47 | 1 | { |
|
| 48 | $this->write('Running <info>generate:scaffold</info> command'); |
||
| 49 | try { |
||
| 50 | 1 | // generate |
|
| 51 | 1 | $this->runGenerateModel(); |
|
| 52 | 1 | $this->runGenerateModule(); |
|
| 53 | 1 | $this->runGenerateCrud(); |
|
| 54 | $this->runGenerateGrid(); |
||
| 55 | |||
| 56 | 1 | // verify it |
|
| 57 | 1 | $this->verify($input, $output); |
|
| 58 | 1 | return 0; |
|
| 59 | } catch (\Exception $e) { |
||
| 60 | 1 | $this->error("ERROR: {$e->getMessage()}"); |
|
| 61 | return $e->getCode(); |
||
| 62 | } |
||
| 63 | } |
||
| 64 | |||
| 65 | /** |
||
| 66 | * Generate Model |
||
| 67 | * |
||
| 68 | 1 | * @return void |
|
| 69 | * @throws \Symfony\Component\Console\Exception\ExceptionInterface |
||
| 70 | 1 | */ |
|
| 71 | protected function runGenerateModel(): void |
||
| 72 | { |
||
| 73 | 1 | $command = $this->getApplication()->find('generate:model'); |
|
| 74 | 1 | ||
| 75 | 1 | $arguments = [ |
|
| 76 | 'command' => 'generate:model', |
||
| 77 | 1 | 'model' => $this->getInput()->getArgument('model'), |
|
| 78 | 1 | 'table' => $this->getInput()->getArgument('table') |
|
| 79 | 1 | ]; |
|
| 80 | $command->run( |
||
| 81 | 1 | new ArrayInput($arguments), |
|
| 82 | $this->getOutput() |
||
| 83 | ); |
||
| 84 | } |
||
| 85 | |||
| 86 | /** |
||
| 87 | * Generate Module |
||
| 88 | * |
||
| 89 | 1 | * @return void |
|
| 90 | * @throws \Symfony\Component\Console\Exception\ExceptionInterface |
||
| 91 | 1 | */ |
|
| 92 | protected function runGenerateModule(): void |
||
| 93 | { |
||
| 94 | 1 | $command = $this->getApplication()->find('generate:module'); |
|
| 95 | 1 | ||
| 96 | $arguments = [ |
||
| 97 | 1 | 'command' => 'generate:module', |
|
| 98 | 1 | 'module' => $this->getInput()->getArgument('module') |
|
| 99 | 1 | ]; |
|
| 100 | $command->run( |
||
| 101 | 1 | new ArrayInput($arguments), |
|
| 102 | $this->getOutput() |
||
| 103 | ); |
||
| 104 | } |
||
| 105 | |||
| 106 | /** |
||
| 107 | * Generate Crud |
||
| 108 | * |
||
| 109 | 1 | * @return void |
|
| 110 | * @throws \Symfony\Component\Console\Exception\ExceptionInterface |
||
| 111 | 1 | */ |
|
| 112 | protected function runGenerateCrud(): void |
||
| 113 | { |
||
| 114 | 1 | $command = $this->getApplication()->find('generate:crud'); |
|
| 115 | 1 | ||
| 116 | 1 | $arguments = [ |
|
| 117 | 'command' => 'generate:crud', |
||
| 118 | 1 | 'model' => $this->getInput()->getArgument('model'), |
|
| 119 | 1 | 'module' => $this->getInput()->getArgument('module') |
|
| 120 | 1 | ]; |
|
| 121 | $command->run( |
||
| 122 | 1 | new ArrayInput($arguments), |
|
| 123 | $this->getOutput() |
||
| 124 | ); |
||
| 125 | } |
||
| 126 | |||
| 127 | /** |
||
| 128 | * Generate Grid |
||
| 129 | * |
||
| 130 | 1 | * @return void |
|
| 131 | * @throws \Symfony\Component\Console\Exception\ExceptionInterface |
||
| 132 | 1 | */ |
|
| 133 | protected function runGenerateGrid(): void |
||
| 134 | { |
||
| 135 | 1 | $command = $this->getApplication()->find('generate:grid'); |
|
| 136 | 1 | ||
| 137 | 1 | $arguments = [ |
|
| 138 | 'command' => 'generate:grid', |
||
| 139 | 1 | 'model' => $this->getInput()->getArgument('model'), |
|
| 140 | 1 | 'module' => $this->getInput()->getArgument('module') |
|
| 141 | 1 | ]; |
|
| 142 | $command->run( |
||
| 143 | 1 | new ArrayInput($arguments), |
|
| 144 | $this->getOutput() |
||
| 145 | ); |
||
| 146 | } |
||
| 147 | |||
| 148 | /** |
||
| 149 | * {@inheritdoc} |
||
| 150 | 1 | * |
|
| 151 | * @throws GeneratorException |
||
| 152 | 1 | */ |
|
| 153 | 1 | public function verify(InputInterface $input, OutputInterface $output): void |
|
| 154 | { |
||
| 155 | 1 | $model = $input->getArgument('model'); |
|
| 156 | 1 | $module = $input->getArgument('module'); |
|
| 157 | |||
| 158 | $modelPath = $this->getApplication()->getModelPath($model); |
||
| 159 | 1 | $modulePath = $this->getApplication()->getModulePath($module); |
|
| 160 | 1 | ||
| 161 | 1 | $paths = [ |
|
| 162 | 1 | $modelPath . DS . 'Crud.php', |
|
|
0 ignored issues
–
show
|
|||
| 163 | 1 | $modelPath . DS . 'Grid.php', |
|
| 164 | 1 | $modelPath . DS . 'Row.php', |
|
| 165 | 1 | $modelPath . DS . 'Table.php', |
|
| 166 | 1 | $modulePath . DS . 'controllers' . DS . 'crud.php', |
|
| 167 | $modulePath . DS . 'controllers' . DS . 'grid.php', |
||
| 168 | $modulePath . DS . 'views' . DS . 'crud.phtml', |
||
| 169 | 1 | $modulePath . DS . 'views' . DS . 'grid.phtml', |
|
| 170 | 1 | ]; |
|
| 171 | 1 | ||
| 172 | foreach ($paths as $path) { |
||
| 173 | if (!$this->getFs()->exists($path)) { |
||
| 174 | throw new GeneratorException("File `$path` is not exists"); |
||
| 175 | } |
||
| 176 | } |
||
| 177 | |||
| 178 | $this->write("Scaffolding for <info>{$model}</info> has been successfully created."); |
||
| 179 | } |
||
| 180 | } |
||
| 181 |
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