|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Enzyme\Axiom\Console\Commands; |
|
4
|
|
|
|
|
5
|
|
|
use Symfony\Component\Console\Input\ArrayInput; |
|
6
|
|
|
use Symfony\Component\Console\Input\InputOption; |
|
7
|
|
|
use Symfony\Component\Console\Input\InputArgument; |
|
8
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
|
9
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
|
10
|
|
|
|
|
11
|
|
|
class MakeStackCommand extends BaseCommand |
|
12
|
|
|
{ |
|
13
|
|
|
/** |
|
14
|
|
|
* {@inheritDoc} |
|
15
|
|
|
*/ |
|
16
|
|
|
protected function getGeneratorType() |
|
17
|
|
|
{ |
|
18
|
|
|
return 'stack'; |
|
19
|
|
|
} |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* {@inheritDoc} |
|
23
|
|
|
*/ |
|
24
|
|
|
protected function configure() |
|
25
|
|
|
{ |
|
26
|
|
|
$generator_type = $this->getGeneratorType(); |
|
27
|
|
|
|
|
28
|
|
|
$this |
|
29
|
|
|
->setName("make:{$generator_type}") |
|
30
|
|
|
->setDescription("Make a new resource stack.") |
|
31
|
|
|
->addArgument( |
|
32
|
|
|
'name', |
|
33
|
|
|
InputArgument::REQUIRED, |
|
34
|
|
|
"The name to prefix on every generated class, eg: \"user\"." |
|
35
|
|
|
) |
|
36
|
|
|
->addOption( |
|
37
|
|
|
'ignore', |
|
38
|
|
|
null, |
|
39
|
|
|
InputOption::VALUE_REQUIRED, |
|
40
|
|
|
'A comma separated list of class types to ignore.' |
|
41
|
|
|
); |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* {@inheritDoc} |
|
46
|
|
|
*/ |
|
47
|
|
|
protected function execute(InputInterface $input, OutputInterface $output) |
|
48
|
|
|
{ |
|
49
|
|
|
$ignore_list = []; |
|
50
|
|
|
$ignore = $input->getOption('ignore'); |
|
51
|
|
|
if (null !== $ignore) { |
|
52
|
|
|
$ignore_list = array_flip(explode(',', $ignore)); |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
$classes = [ |
|
56
|
|
|
'bag', 'factory', 'model', 'repository', |
|
57
|
|
|
]; |
|
58
|
|
|
|
|
59
|
|
|
$name = $input->getArgument('name'); |
|
60
|
|
|
foreach ($classes as $class) { |
|
61
|
|
|
if (isset($ignore_list[$class]) === true) { |
|
62
|
|
|
continue; |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
$command = $this->getApplication()->find("make:{$class}"); |
|
66
|
|
|
$arguments = array( |
|
67
|
|
|
'name' => $name, |
|
68
|
|
|
); |
|
69
|
|
|
$input = new ArrayInput($arguments); |
|
70
|
|
|
$command->run($input, $output); |
|
71
|
|
|
} |
|
72
|
|
|
} |
|
73
|
|
|
} |
|
74
|
|
|
|