1
|
|
|
<?php |
2
|
|
|
/* |
3
|
|
|
* This file is part of Pomm's Cli package. |
4
|
|
|
* |
5
|
|
|
* (c) 2014 - 2015 Grégoire HUBERT <[email protected]> |
6
|
|
|
* |
7
|
|
|
* For the full copyright and license information, please view the LICENSE |
8
|
|
|
* file that was distributed with this source code. |
9
|
|
|
*/ |
10
|
|
|
namespace PommProject\Cli\Command; |
11
|
|
|
|
12
|
|
|
use PommProject\Foundation\ParameterHolder; |
13
|
|
|
use PommProject\ModelManager\Generator\StructureGenerator; |
14
|
|
|
use Symfony\Component\Console\Command\Command; |
15
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
16
|
|
|
use Symfony\Component\Console\Input\InputOption; |
17
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* GenerateRelationStructure |
21
|
|
|
* |
22
|
|
|
* Command to scan a relation and (re)build the according structure file. |
23
|
|
|
* |
24
|
|
|
* @package Cli |
25
|
|
|
* @copyright 2014 - 2015 Grégoire HUBERT |
26
|
|
|
* @author Grégoire HUBERT |
27
|
|
|
* @license X11 {@link http://opensource.org/licenses/mit-license.php} |
28
|
|
|
* @see Command |
29
|
|
|
*/ |
30
|
|
|
class GenerateRelationStructure extends RelationAwareCommand |
31
|
|
|
{ |
32
|
|
|
/** |
33
|
|
|
* configure |
34
|
|
|
* |
35
|
|
|
* @see Command |
36
|
|
|
*/ |
37
|
|
|
protected function configure() |
38
|
|
|
{ |
39
|
|
|
$this |
40
|
|
|
->setName('pomm:generate:structure') |
41
|
|
|
->setDescription('Generate a RowStructure file based on table schema.') |
42
|
|
|
->setHelp(<<<HELP |
43
|
|
|
HELP |
44
|
|
|
) |
45
|
|
|
; |
46
|
|
|
parent::configure(); |
47
|
|
|
$this |
48
|
|
|
->addOption( |
49
|
|
|
'psr4', |
50
|
|
|
null, |
51
|
|
|
InputOption::VALUE_NONE, |
52
|
|
|
'Use PSR4 structure.' |
53
|
|
|
) |
54
|
|
|
->addOption( |
55
|
|
|
'path-pattern', |
56
|
|
|
null, |
57
|
|
|
InputOption::VALUE_REQUIRED, |
58
|
|
|
'Use a different directory pattern when generating classes.', |
59
|
|
|
'{session}/{schema}Schema' |
60
|
|
|
) |
61
|
|
|
; |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* execute |
66
|
|
|
* |
67
|
|
|
* @see Command |
68
|
|
|
*/ |
69
|
|
|
protected function execute(InputInterface $input, OutputInterface $output) |
70
|
|
|
{ |
71
|
|
|
parent::execute($input, $output); |
72
|
|
|
|
73
|
|
|
$session = $this->mustBeModelManagerSession($this->getSession()); |
74
|
|
|
|
75
|
|
|
$this->pathFile = $this->getPathFile( |
76
|
|
|
$input->getArgument('config-name'), |
|
|
|
|
77
|
|
|
$this->relation, |
|
|
|
|
78
|
|
|
null, |
79
|
|
|
'AutoStructure', |
80
|
|
|
$input->getOption('psr4'), |
81
|
|
|
$input->getOption('path-pattern') |
82
|
|
|
); |
83
|
|
|
$this->namespace = $this->getNamespace($input->getArgument('config-name'), 'AutoStructure', $input->getOption('path-pattern')); |
|
|
|
|
84
|
|
|
|
85
|
|
|
$this->updateOutput( |
86
|
|
|
$output, |
87
|
|
|
(new StructureGenerator( |
88
|
|
|
$session, |
89
|
|
|
$this->schema, |
|
|
|
|
90
|
|
|
$this->relation, |
|
|
|
|
91
|
|
|
$this->pathFile, |
92
|
|
|
$this->namespace |
93
|
|
|
))->generate(new ParameterHolder()) |
94
|
|
|
); |
95
|
|
|
|
96
|
|
|
return 0; |
97
|
|
|
} |
98
|
|
|
} |
99
|
|
|
|
This check looks at variables that are passed out again to other methods.
If the outgoing method call has stricter type requirements than the method itself, an issue is raised.
An additional type check may prevent trouble.