@@ 7-77 (lines=71) @@ | ||
4 | ||
5 | use Symfony\Component\Console\Input\InputOption; |
|
6 | ||
7 | class MakeControllerCommand extends HiveGeneratorCommand |
|
8 | { |
|
9 | /** |
|
10 | * The console command name. |
|
11 | * |
|
12 | * @var string |
|
13 | */ |
|
14 | protected $name = 'hive:controller'; |
|
15 | ||
16 | /** |
|
17 | * The console command description. |
|
18 | * |
|
19 | * @var string |
|
20 | */ |
|
21 | protected $description = 'Create a new Hive controller class.'; |
|
22 | ||
23 | /** |
|
24 | * The type of class being generated. |
|
25 | * |
|
26 | * @var string |
|
27 | */ |
|
28 | protected $type = 'Controller'; |
|
29 | ||
30 | /** |
|
31 | * Execute the console command. |
|
32 | * |
|
33 | * @return void |
|
34 | */ |
|
35 | public function fire() |
|
36 | { |
|
37 | parent::fire(); |
|
38 | } |
|
39 | ||
40 | /** |
|
41 | * Get the stub file for the generator. |
|
42 | * |
|
43 | * @return string |
|
44 | */ |
|
45 | protected function getStub() |
|
46 | { |
|
47 | return __DIR__.'/stubs/controller.stub'; |
|
48 | } |
|
49 | ||
50 | /** |
|
51 | * Get the default namespace for the class. |
|
52 | * |
|
53 | * @param string $rootNamespace |
|
54 | * |
|
55 | * @return string |
|
56 | */ |
|
57 | protected function getDefaultNamespace($rootNamespace) |
|
58 | { |
|
59 | if ($this->option('subfolder')) { |
|
60 | return $rootNamespace.'\Http\Controllers\\'.$this->option('subfolder'); |
|
61 | } |
|
62 | ||
63 | return $rootNamespace.'\Http\Controllers'; |
|
64 | } |
|
65 | ||
66 | /** |
|
67 | * Get the console command options. |
|
68 | * |
|
69 | * @return array |
|
70 | */ |
|
71 | protected function getOptions() |
|
72 | { |
|
73 | return [ |
|
74 | ['subfolder', 's', InputOption::VALUE_OPTIONAL, 'The subfolder to place the controller into.'], |
|
75 | ]; |
|
76 | } |
|
77 | } |
|
78 |
@@ 7-74 (lines=68) @@ | ||
4 | ||
5 | use Symfony\Component\Console\Input\InputOption; |
|
6 | ||
7 | class MakeFactoryCommand extends HiveGeneratorCommand |
|
8 | { |
|
9 | /** |
|
10 | * The console command name. |
|
11 | * |
|
12 | * @var string |
|
13 | */ |
|
14 | protected $name = 'hive:factory'; |
|
15 | ||
16 | /** |
|
17 | * The console command description. |
|
18 | * |
|
19 | * @var string |
|
20 | */ |
|
21 | protected $description = 'Create a new Hive factory class.'; |
|
22 | ||
23 | /** |
|
24 | * The type of class being generated. |
|
25 | * |
|
26 | * @var string |
|
27 | */ |
|
28 | protected $type = 'Factory'; |
|
29 | ||
30 | /** |
|
31 | * The compound command to fire after the parent succeeds. |
|
32 | * |
|
33 | * @var string |
|
34 | */ |
|
35 | protected $compound = 'validator'; |
|
36 | ||
37 | /** |
|
38 | * Get the stub file for the generator. |
|
39 | * |
|
40 | * @return string |
|
41 | */ |
|
42 | protected function getStub() |
|
43 | { |
|
44 | if ($this->option('validator')) { |
|
45 | return __DIR__.'/stubs/factory-validator.stub'; |
|
46 | } else { |
|
47 | return __DIR__.'/stubs/factory-no-validator.stub'; |
|
48 | } |
|
49 | } |
|
50 | ||
51 | /** |
|
52 | * Get the default namespace for the class. |
|
53 | * |
|
54 | * @param string $rootNamespace |
|
55 | * |
|
56 | * @return string |
|
57 | */ |
|
58 | protected function getDefaultNamespace($rootNamespace) |
|
59 | { |
|
60 | return $rootNamespace.'\Lib\Factories'; |
|
61 | } |
|
62 | ||
63 | /** |
|
64 | * Get the console command options. |
|
65 | * |
|
66 | * @return array |
|
67 | */ |
|
68 | protected function getOptions() |
|
69 | { |
|
70 | return [ |
|
71 | ['validator', 'i', InputOption::VALUE_NONE, 'Create a new associated validator.'], |
|
72 | ]; |
|
73 | } |
|
74 | } |
|
75 |
@@ 7-77 (lines=71) @@ | ||
4 | ||
5 | use Symfony\Component\Console\Input\InputOption; |
|
6 | ||
7 | class MakeRepoCommand extends HiveGeneratorCommand |
|
8 | { |
|
9 | /** |
|
10 | * The console command name. |
|
11 | * |
|
12 | * @var string |
|
13 | */ |
|
14 | protected $name = 'hive:repo'; |
|
15 | ||
16 | /** |
|
17 | * The console command description. |
|
18 | * |
|
19 | * @var string |
|
20 | */ |
|
21 | protected $description = 'Create a new Hive repo class.'; |
|
22 | ||
23 | /** |
|
24 | * The type of class being generated. |
|
25 | * |
|
26 | * @var string |
|
27 | */ |
|
28 | protected $type = 'Repo'; |
|
29 | ||
30 | /** |
|
31 | * Execute the console command. |
|
32 | * |
|
33 | * @return void |
|
34 | */ |
|
35 | public function fire() |
|
36 | { |
|
37 | parent::fire(); |
|
38 | } |
|
39 | ||
40 | /** |
|
41 | * Get the stub file for the generator. |
|
42 | * |
|
43 | * @return string |
|
44 | */ |
|
45 | protected function getStub() |
|
46 | { |
|
47 | if ($this->option('observatory')) { |
|
48 | return __DIR__.'/stubs/repo-observatory.stub'; |
|
49 | } else { |
|
50 | return __DIR__.'/stubs/repo-no-observatory.stub'; |
|
51 | } |
|
52 | } |
|
53 | ||
54 | /** |
|
55 | * Get the default namespace for the class. |
|
56 | * |
|
57 | * @param string $rootNamespace |
|
58 | * |
|
59 | * @return string |
|
60 | */ |
|
61 | protected function getDefaultNamespace($rootNamespace) |
|
62 | { |
|
63 | return $rootNamespace.'\Lib\Repos'; |
|
64 | } |
|
65 | ||
66 | /** |
|
67 | * Get the console command options. |
|
68 | * |
|
69 | * @return array |
|
70 | */ |
|
71 | protected function getOptions() |
|
72 | { |
|
73 | return [ |
|
74 | ['observatory', 'o', InputOption::VALUE_NONE, 'Add observatory support to this repo.'], |
|
75 | ]; |
|
76 | } |
|
77 | } |
|
78 |