1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Kunstmaan\GeneratorBundle\Command; |
4
|
|
|
|
5
|
|
|
use Kunstmaan\GeneratorBundle\Generator\ConfigGenerator; |
6
|
|
|
use Symfony\Component\Console\Input\InputOption; |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* Generates config files |
10
|
|
|
*/ |
11
|
|
|
class GenerateConfigCommand extends KunstmaanGenerateCommand |
12
|
|
|
{ |
13
|
|
|
/** @var bool */ |
14
|
|
|
private $overwriteSecurity; |
15
|
|
|
|
16
|
|
|
/** @var bool */ |
17
|
|
|
private $overwriteLiipImagine; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* @param string $rootDir |
|
|
|
|
21
|
|
|
*/ |
22
|
|
|
public function __construct(string $projectDir) |
23
|
|
|
{ |
24
|
|
|
$this->projectDir = $projectDir; |
|
|
|
|
25
|
|
|
|
26
|
|
|
parent::__construct(); |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* @see Command |
31
|
|
|
*/ |
32
|
|
|
protected function configure() |
33
|
|
|
{ |
34
|
|
|
$this->setDescription('Generates all needed config files not generated by recipes') |
35
|
|
|
->addOption('overwrite-security', '', InputOption::VALUE_REQUIRED, 'Whether the command should generate a copy or just overwrite the already existing config file') |
36
|
|
|
->addOption('overwrite-liipimagine', '', InputOption::VALUE_REQUIRED, 'Whether the command should generate a copy or just overwrite the already existing config file') |
37
|
|
|
->setName('kuma:generate:config'); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* {@inheritdoc} |
42
|
|
|
*/ |
43
|
|
|
protected function getWelcomeText() |
44
|
|
|
{ |
45
|
|
|
return 'Welcome to the Kunstmaan config generator'; |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* {@inheritdoc} |
50
|
|
|
*/ |
51
|
|
|
protected function doExecute() |
52
|
|
|
{ |
53
|
|
|
$this->assistant->writeSection('Config generation'); |
54
|
|
|
|
55
|
|
|
$this->createGenerator()->generate($this->projectDir, $this->overwriteSecurity, $this->overwriteLiipImagine); |
56
|
|
|
|
57
|
|
|
$this->assistant->writeSection('Config successfully created', 'bg=green;fg=black'); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* {@inheritdoc} |
62
|
|
|
*/ |
63
|
|
|
protected function doInteract() |
64
|
|
|
{ |
65
|
|
|
$this->assistant->writeLine(array("This helps you to set all default config files needed to run KunstmaanCMS.\n")); |
66
|
|
|
|
67
|
|
|
$this->overwriteSecurity = $this->assistant->getOptionOrDefault('overwrite-security', null); |
68
|
|
|
$this->overwriteLiipImagine = $this->assistant->getOptionOrDefault('overwrite-liipimagine', null); |
69
|
|
|
|
70
|
|
|
if (null === $this->overwriteSecurity) { |
71
|
|
|
$this->overwriteSecurity = $this->assistant->askConfirmation('Do you want to overwrite the default security.yaml configuration file? (y/n)', 'y'); |
72
|
|
|
} |
73
|
|
|
if (null === $this->overwriteLiipImagine) { |
74
|
|
|
$this->overwriteLiipImagine = $this->assistant->askConfirmation('Do you want to overwrite the default liip_imagine.yaml configuration file? (y/n)', 'y'); |
75
|
|
|
} |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* @return ConfigGenerator |
80
|
|
|
*/ |
81
|
|
View Code Duplication |
protected function createGenerator() |
|
|
|
|
82
|
|
|
{ |
83
|
|
|
$filesystem = $this->getContainer()->get('filesystem'); |
84
|
|
|
$registry = $this->getContainer()->get('doctrine'); |
85
|
|
|
|
86
|
|
|
return new ConfigGenerator($filesystem, $registry, '/config', $this->assistant, $this->getContainer()); |
87
|
|
|
} |
88
|
|
|
} |
89
|
|
|
|
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italy
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was removed, but the annotation was not.