@@ 30-106 (lines=77) @@ | ||
27 | * @license X11 {@link http://opensource.org/licenses/mit-license.php} |
|
28 | * @see PommAwareCommand |
|
29 | */ |
|
30 | class GenerateEntity extends RelationAwareCommand |
|
31 | { |
|
32 | /** |
|
33 | * configure |
|
34 | * |
|
35 | * @see Command |
|
36 | */ |
|
37 | protected function configure() |
|
38 | { |
|
39 | $this |
|
40 | ->setName('pomm:generate:entity') |
|
41 | ->setDescription('Generate an Entity class.') |
|
42 | ->setHelp(<<<HELP |
|
43 | This command generates an empty FlexibleEntity class in the given directory with the given namespace. By default, it creates a tree structure in the following format: ConfigName/NameSchema. |
|
44 | ||
45 | In order to comply with the project’s autoloading rules, it is possible to prefix this directory structure and / or namespace: |
|
46 | ||
47 | <info>pomm:generate:entity -d sources/lib/Model -a 'Vendor\Project\Model' --psr4 builder_name</info> |
|
48 | ||
49 | HELP |
|
50 | ) |
|
51 | ; |
|
52 | parent::configure(); |
|
53 | } |
|
54 | ||
55 | /** |
|
56 | * configureOptionals |
|
57 | * |
|
58 | * @see PommAwareCommand |
|
59 | */ |
|
60 | protected function configureOptionals() |
|
61 | { |
|
62 | parent::configureOptionals() |
|
63 | ->addOption( |
|
64 | 'force', |
|
65 | null, |
|
66 | InputOption::VALUE_NONE, |
|
67 | 'Force overwriting an existing file.' |
|
68 | ) |
|
69 | ->addOption( |
|
70 | 'psr4', |
|
71 | null, |
|
72 | InputOption::VALUE_NONE, |
|
73 | 'Use PSR4 structure.' |
|
74 | ) |
|
75 | ; |
|
76 | ||
77 | return $this; |
|
78 | } |
|
79 | ||
80 | /** |
|
81 | * execute |
|
82 | * |
|
83 | * @see Command |
|
84 | */ |
|
85 | protected function execute(InputInterface $input, OutputInterface $output) |
|
86 | { |
|
87 | parent::execute($input, $output); |
|
88 | ||
89 | $session = $this->mustBeModelManagerSession($this->getSession()); |
|
90 | ||
91 | $this->pathFile = $this->getPathFile($input->getArgument('config-name'), $this->relation, '', '', $input->getOption('psr4')); |
|
92 | $this->namespace = $this->getNamespace($input->getArgument('config-name')); |
|
93 | ||
94 | $this->updateOutput( |
|
95 | $output, |
|
96 | (new EntityGenerator( |
|
97 | $session, |
|
98 | $this->schema, |
|
99 | $this->relation, |
|
100 | $this->pathFile, |
|
101 | $this->namespace, |
|
102 | $this->flexible_container |
|
103 | ))->generate(new ParameterHolder(['force' => $input->getOption('force')])) |
|
104 | ); |
|
105 | } |
|
106 | } |
|
107 |
@@ 30-85 (lines=56) @@ | ||
27 | * @license X11 {@link http://opensource.org/licenses/mit-license.php} |
|
28 | * @see PommAwareCommand |
|
29 | */ |
|
30 | class GenerateRelationModel extends RelationAwareCommand |
|
31 | { |
|
32 | /** |
|
33 | * configure |
|
34 | * |
|
35 | * @see Command |
|
36 | */ |
|
37 | public function configure() |
|
38 | { |
|
39 | $this |
|
40 | ->setName('pomm:generate:model') |
|
41 | ->setDescription('Generate a new model file.') |
|
42 | ; |
|
43 | parent::configure(); |
|
44 | $this |
|
45 | ->addOption( |
|
46 | 'force', |
|
47 | null, |
|
48 | InputOption::VALUE_NONE, |
|
49 | 'Force overwriting an existing file.' |
|
50 | ) |
|
51 | ->addOption( |
|
52 | 'psr4', |
|
53 | null, |
|
54 | InputOption::VALUE_NONE, |
|
55 | 'Use PSR4 structure.' |
|
56 | ) |
|
57 | ; |
|
58 | } |
|
59 | ||
60 | /** |
|
61 | * execute |
|
62 | * |
|
63 | * @see Command |
|
64 | */ |
|
65 | protected function execute(InputInterface $input, OutputInterface $output) |
|
66 | { |
|
67 | parent::execute($input, $output); |
|
68 | ||
69 | $session = $this->mustBeModelManagerSession($this->getSession()); |
|
70 | ||
71 | $this->pathFile = $this->getPathFile($input->getArgument('config-name'), $this->relation, 'Model', '', $input->getOption('psr4')); |
|
72 | $this->namespace = $this->getNamespace($input->getArgument('config-name')); |
|
73 | ||
74 | $this->updateOutput( |
|
75 | $output, |
|
76 | (new ModelGenerator( |
|
77 | $session, |
|
78 | $this->schema, |
|
79 | $this->relation, |
|
80 | $this->pathFile, |
|
81 | $this->namespace |
|
82 | ))->generate(new ParameterHolder(['force' => $input->getOption('force')])) |
|
83 | ); |
|
84 | } |
|
85 | } |
|
86 |