1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* generator command |
4
|
|
|
*/ |
5
|
|
|
|
6
|
|
|
namespace Graviton\GeneratorBundle\Command; |
7
|
|
|
|
8
|
|
|
use Graviton\GeneratorBundle\Generator\BundleGenerator; |
9
|
|
|
use Graviton\GeneratorBundle\Manipulator\BundleBundleManipulator; |
10
|
|
|
use Sensio\Bundle\GeneratorBundle\Command\GenerateBundleCommand as SymfonyGenerateBundleCommand; |
11
|
|
|
use Sensio\Bundle\GeneratorBundle\Command\Helper\QuestionHelper; |
12
|
|
|
use Sensio\Bundle\GeneratorBundle\Model\Bundle; |
13
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
14
|
|
|
use Symfony\Component\Console\Input\InputOption; |
15
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
16
|
|
|
use Symfony\Component\Filesystem\Filesystem; |
17
|
|
|
use Symfony\Component\HttpKernel\KernelInterface; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* generator command |
21
|
|
|
* |
22
|
|
|
* @author List of contributors <https://github.com/libgraviton/graviton/graphs/contributors> |
23
|
|
|
* @license http://opensource.org/licenses/gpl-license.php GNU Public License |
24
|
|
|
* @link http://swisscom.ch |
25
|
|
|
*/ |
26
|
|
|
class GenerateBundleCommand extends SymfonyGenerateBundleCommand |
27
|
|
|
{ |
28
|
|
|
/** |
29
|
|
|
* @var string |
30
|
|
|
*/ |
31
|
|
|
private $loaderBundleName; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* {@inheritDoc} |
35
|
|
|
* |
36
|
|
|
* @return void |
37
|
|
|
*/ |
38
|
18 |
|
protected function configure() |
39
|
|
|
{ |
40
|
18 |
|
parent::configure(); |
41
|
|
|
|
42
|
18 |
|
$this->addOption( |
43
|
18 |
|
'loaderBundleName', |
44
|
18 |
|
'lbn', |
45
|
18 |
|
InputOption::VALUE_OPTIONAL, |
46
|
18 |
|
'Name of the bundle to manipulate, defaults to GravitonCoreBundle', |
47
|
18 |
|
'GravitonCoreBundle' |
48
|
|
|
) |
49
|
18 |
|
->addOption( |
50
|
18 |
|
'deleteBefore', |
51
|
18 |
|
'delbef', |
52
|
18 |
|
InputOption::VALUE_OPTIONAL, |
53
|
18 |
|
'If a string, that directory will be deleted prior to generation', |
54
|
18 |
|
null |
55
|
|
|
) |
56
|
18 |
|
->setName('graviton:generate:bundle') |
57
|
18 |
|
->setDescription('Generates a graviton bundle'); |
58
|
18 |
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* {@inheritDoc} |
62
|
|
|
* |
63
|
|
|
* @param InputInterface $input input |
64
|
|
|
* @param OutputInterface $output output |
65
|
|
|
* |
66
|
|
|
* @return void |
67
|
|
|
*/ |
68
|
14 |
|
protected function execute(InputInterface $input, OutputInterface $output) |
69
|
|
|
{ |
70
|
14 |
|
$this->loaderBundleName = $input->getOption('loaderBundleName'); |
71
|
|
|
|
72
|
14 |
|
$deleteBefore = $input->getOption('deleteBefore'); |
73
|
14 |
|
$fs = new Filesystem(); |
74
|
14 |
|
if ($deleteBefore != null && $fs->exists($deleteBefore)) { |
75
|
|
|
$fs->remove($deleteBefore); |
76
|
|
|
} |
77
|
|
|
|
78
|
14 |
|
parent::execute( |
79
|
14 |
|
$input, |
80
|
14 |
|
$output |
81
|
|
|
); |
82
|
14 |
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* {@inheritDoc} |
86
|
|
|
* Add the new bundle to the BundleBundle loader infrastructure instead of main kernel |
87
|
|
|
* |
88
|
|
|
* @param OutputInterface $output output |
89
|
|
|
* @param KernelInterface $kernel kernel |
90
|
|
|
* @param Bundle $bundle bundle |
91
|
|
|
* |
92
|
|
|
* @return string[] |
|
|
|
|
93
|
|
|
*/ |
94
|
|
|
protected function updateKernel(OutputInterface $output, KernelInterface $kernel, Bundle $bundle) |
95
|
|
|
{ |
96
|
|
|
return; |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
/** |
100
|
|
|
* {@inheritDoc} |
101
|
|
|
* Don't check routing since graviton bundles usually get routed explicitly based on their naming. |
102
|
|
|
* |
103
|
|
|
* @param OutputInterface $output output |
104
|
|
|
* @param Bundle $bundle bundle |
105
|
|
|
* |
106
|
|
|
* @return string[] |
107
|
|
|
*/ |
108
|
14 |
|
protected function updateRouting(OutputInterface $output, Bundle $bundle) |
109
|
|
|
{ |
110
|
14 |
|
return []; |
111
|
|
|
} |
112
|
|
|
|
113
|
|
|
/** |
114
|
|
|
* {@inheritDoc} |
115
|
|
|
* Don't do anything with the configuration since we load our bundles dynamically using the bundle-bundle-bundle |
116
|
|
|
* |
117
|
|
|
* @param OutputInterface $output output |
118
|
|
|
* @param Bundle $bundle bundle |
119
|
|
|
* |
120
|
|
|
* @return void |
121
|
|
|
*/ |
122
|
4 |
|
protected function updateConfiguration(OutputInterface $output, Bundle $bundle) |
123
|
|
|
{ |
124
|
4 |
|
return; |
125
|
|
|
} |
126
|
|
|
|
127
|
|
|
/** |
128
|
|
|
* {@inheritDoc} |
129
|
|
|
* Use an overridden generator to make nicer code |
130
|
|
|
* |
131
|
|
|
* @return BundleGenerator |
132
|
|
|
*/ |
133
|
|
|
protected function createGenerator() |
134
|
|
|
{ |
135
|
|
|
return new BundleGenerator(); |
136
|
|
|
} |
137
|
|
|
} |
138
|
|
|
|
This check compares the return type specified in the
@return
annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.