|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Rougin\Combustor\Commands; |
|
4
|
|
|
|
|
5
|
|
|
use Symfony\Component\Console\Input\ArrayInput; |
|
6
|
|
|
use Symfony\Component\Console\Input\InputArgument; |
|
7
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
|
8
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
|
9
|
|
|
|
|
10
|
|
|
/** |
|
11
|
|
|
* Make Scaffold Command |
|
12
|
|
|
* |
|
13
|
|
|
* @package Combustor |
|
14
|
|
|
* @author Rougin Royce Gutib <[email protected]> |
|
15
|
|
|
*/ |
|
16
|
|
|
class MakeScaffoldCommand extends AbstractCommand |
|
17
|
|
|
{ |
|
18
|
|
|
/** |
|
19
|
|
|
* Set the configurations of the specified command. |
|
20
|
|
|
* |
|
21
|
|
|
* @return void |
|
22
|
|
|
*/ |
|
23
|
6 |
|
protected function configure() |
|
24
|
|
|
{ |
|
25
|
6 |
|
$this->setName('make:scaffold')->setDescription('Create a new controller class, model class, and view folder'); |
|
26
|
6 |
|
$this->addArgument('table', InputArgument::REQUIRED, 'Name of the table'); |
|
27
|
6 |
|
$this->addOption('type', null, InputArgument::OPTIONAL, 'Type of model: "credo" or "wildfire"', 'wildfire'); |
|
28
|
6 |
|
} |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* Executes the current command. |
|
32
|
|
|
* |
|
33
|
|
|
* @param \Symfony\Component\Console\Input\InputInterface $input |
|
34
|
|
|
* @param \Symfony\Component\Console\Input\OutputInterface $output |
|
35
|
|
|
* @return void |
|
36
|
|
|
*/ |
|
37
|
3 |
|
protected function execute(InputInterface $input, OutputInterface $output) |
|
38
|
|
|
{ |
|
39
|
3 |
|
$commands = [ 'make:controller', 'make:model', 'make:view' ]; |
|
40
|
|
|
|
|
41
|
3 |
|
foreach ($commands as $command) { |
|
42
|
3 |
|
$arguments = [ 'command' => $command, 'table' => $input->getArgument('table') ]; |
|
43
|
|
|
|
|
44
|
3 |
|
if ($command == 'make:model') { |
|
45
|
3 |
|
$arguments['--type'] = $input->getOption('type'); |
|
46
|
3 |
|
} |
|
47
|
|
|
|
|
48
|
3 |
|
$application = $this->getApplication()->find($command); |
|
49
|
|
|
|
|
50
|
3 |
|
$application->run(new ArrayInput($arguments), $output); |
|
51
|
3 |
|
} |
|
52
|
3 |
|
} |
|
53
|
|
|
} |
|
54
|
|
|
|