-
-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathGenerateControllerCommand.php
More file actions
45 lines (36 loc) · 1.05 KB
/
GenerateControllerCommand.php
File metadata and controls
45 lines (36 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php
declare(strict_types=1);
namespace Bow\Console\Command;
use Bow\Console\AbstractCommand;
use Bow\Console\Generator;
class GenerateControllerCommand extends AbstractCommand
{
/**
* The add controller command
*
* @param string $controller
* @return void
*/
public function run(string $controller): void
{
$generator = new Generator(
$this->setting->getControllerDirectory(),
$controller
);
if ($generator->fileExists()) {
echo "\033[0;31mThe controller already exists.\033[00m\n";
exit(1);
}
if ($this->arg->getParameter('--no-plain')) {
$generator->write('controller/no-plain', [
'baseNamespace' => $this->namespaces['controller']
]);
} else {
$generator->write('controller/controller', [
'baseNamespace' => $this->namespaces['controller']
]);
}
echo "\033[0;32mThe controller was well created.\033[00m\n";
exit(0);
}
}