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\InputException; |
||
11 | use Bluzman\Generator; |
||
12 | use Symfony\Component\Console\Input\InputInterface; |
||
0 ignored issues
–
show
|
|||
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 ![]() |
|||
14 | |||
15 | /** |
||
16 | * ModelCommand |
||
17 | * |
||
18 | * @package Bluzman\Command\Generate |
||
19 | */ |
||
20 | class RestCommand 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:rest') |
||
30 | 15 | // the short description shown while running "php bin/bluzman list" |
|
31 | ->setDescription('Generate a REST controller') |
||
32 | // the full command description shown when running the command with |
||
33 | 15 | // the "--help" option |
|
34 | ->setHelp('This command allows you to generate REST controller') |
||
35 | ; |
||
36 | 15 | ||
37 | 15 | $this->addModelArgument(); |
|
38 | 15 | $this->addModuleArgument(); |
|
39 | 15 | $this->addForceOption(); |
|
40 | } |
||
41 | |||
42 | /** |
||
43 | * {@inheritdoc} |
||
44 | 1 | */ |
|
45 | protected function execute(InputInterface $input, OutputInterface $output) |
||
46 | 1 | { |
|
47 | $this->write('Running <info>generate:rest</info> command'); |
||
48 | try { |
||
49 | 1 | // validate |
|
50 | 1 | $this->validateModelArgument(); |
|
51 | $this->validateModuleArgument(); |
||
52 | |||
53 | 1 | // generate directories and files |
|
54 | $this->generate($input, $output); |
||
55 | |||
56 | 1 | // verify it |
|
57 | $this->verify($input, $output); |
||
58 | return 0; |
||
59 | } catch (InputException $e) { |
||
60 | 1 | $this->error("ERROR: {$e->getMessage()}"); |
|
61 | return $e->getCode(); |
||
62 | } |
||
63 | } |
||
64 | |||
65 | /** |
||
66 | * @param InputInterface $input |
||
67 | * @param OutputInterface $output |
||
68 | 1 | * @return void |
|
69 | * @throws InputException |
||
70 | 1 | */ |
|
71 | 1 | protected function generate(InputInterface $input, OutputInterface $output): void |
|
72 | { |
||
73 | 1 | $model = ucfirst($input->getArgument('model')); |
|
74 | 1 | $module = $input->getArgument('module'); |
|
75 | $data = [ |
||
76 | 'model' => $model, |
||
77 | 1 | 'module' => $module |
|
78 | 1 | ]; |
|
79 | |||
80 | $crudPath = $this->getApplication()->getModelPath($model) . DS . 'Crud.php'; |
||
0 ignored issues
–
show
|
|||
81 | if (!is_file($crudPath)) { |
||
82 | throw new InputException( |
||
83 | "CRUD for $model is not exist, " . |
||
84 | "run command <question>bluzman generate:crud $model</question> before" |
||
85 | 1 | ); |
|
86 | } |
||
87 | 1 | ||
88 | 1 | $this->write(" |> Generate <info>$module/controllers/rest.php</info>"); |
|
89 | 1 | ||
90 | $controllerFile = $this->getControllerPath($module, 'rest'); |
||
91 | $this->generateFile('RestTemplate', $controllerFile, $data); |
||
92 | } |
||
93 | |||
94 | /** |
||
95 | * @param InputInterface $input |
||
96 | * @param OutputInterface $output |
||
97 | 1 | * @return void |
|
98 | * @throws \Bluzman\Generator\GeneratorException |
||
99 | 1 | */ |
|
100 | 1 | public function verify(InputInterface $input, OutputInterface $output): void |
|
101 | { |
||
102 | 1 | $model = $input->getArgument('model'); |
|
103 | $module = $input->getArgument('module'); |
||
104 | |||
105 | 1 | $modulePath = $this->getApplication()->getModulePath($module); |
|
106 | |||
107 | $paths = [ |
||
108 | 1 | $modulePath . DS . 'controllers' . DS . 'rest.php', |
|
0 ignored issues
–
show
|
|||
109 | 1 | ]; |
|
110 | 1 | ||
111 | foreach ($paths as $path) { |
||
112 | if (!$this->getFs()->exists($path)) { |
||
113 | throw new Generator\GeneratorException("File `$path` is not exists"); |
||
114 | 1 | } |
|
115 | 1 | } |
|
116 | |||
117 | 1 | $this->write(" |> REST for <info>{$model}</info> has been successfully created."); |
|
118 | $this->write( |
||
119 | 1 | " |> <options=bold>Open page <info>/acl</info> in your browser " . |
|
120 | "and set permissions <info>Management</info> for <info>{$module}</info> module</>" |
||
121 | ); |
||
122 | } |
||
123 | } |
||
124 |
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