This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | /* |
||
4 | * This file is part of EC-CUBE |
||
5 | * |
||
6 | * Copyright(c) 2000-2015 LOCKON CO.,LTD. All Rights Reserved. |
||
7 | * |
||
8 | * http://www.lockon.co.jp/ |
||
9 | * |
||
10 | * This program is free software; you can redistribute it and/or |
||
11 | * modify it under the terms of the GNU General Public License |
||
12 | * as published by the Free Software Foundation; either version 2 |
||
13 | * of the License, or (at your option) any later version. |
||
14 | * |
||
15 | * This program is distributed in the hope that it will be useful, |
||
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
18 | * GNU General Public License for more details. |
||
19 | * |
||
20 | * You should have received a copy of the GNU General Public License |
||
21 | * along with this program; if not, write to the Free Software |
||
22 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
||
23 | */ |
||
24 | |||
25 | namespace Eccube\Command\GeneratorCommand; |
||
26 | |||
27 | use Doctrine\ORM\Mapping\ClassMetadataInfo; |
||
28 | use Eccube\Doctrine\ORM\Mapping\Driver\YamlDriver; |
||
29 | use Symfony\Component\Finder\Finder; |
||
30 | use Symfony\Component\Yaml\Yaml; |
||
31 | |||
32 | class EntityFromYamlGenerator extends AbstractPluginGenerator |
||
33 | { |
||
34 | |||
35 | /** |
||
36 | * Yamlリスト |
||
37 | * |
||
38 | * @var array |
||
39 | */ |
||
40 | private $ymlList = null; |
||
41 | |||
42 | View Code Duplication | protected function getHeader() |
|
43 | { |
||
44 | $this->output->writeln('------------------------------------------------------'); |
||
45 | $this->output->writeln('---Plugin Generator for Entity'); |
||
46 | $this->output->writeln('---[*]You need to create yml file first.'); |
||
47 | $this->output->writeln('---[*]You can exit from Console Application, by typing '.self::STOP_PROCESS.' instead of typing another word.'); |
||
48 | $this->output->writeln('------------------------------------------------------'); |
||
49 | $this->output->writeln(''); |
||
50 | } |
||
51 | |||
52 | View Code Duplication | protected function initFieldSet() |
|
0 ignored issues
–
show
|
|||
53 | { |
||
54 | $this->paramList = array( |
||
55 | 'pluginCode' => array( |
||
56 | 'no' => 1, |
||
57 | 'label' => '[+]Plugin Code: ', |
||
58 | 'value' => null, |
||
59 | 'name' => '[+]Please enter Plugin Code (First letter is uppercase alphabet only. alphabet and numbers are allowed.)', |
||
60 | 'validation' => array( |
||
61 | 'isRequired' => true, |
||
62 | 'isNotCode' => $this->getPluginCodes(), |
||
63 | ) |
||
64 | ), |
||
65 | 'ymlList' => array( |
||
0 ignored issues
–
show
|
|||
66 | 'no' => 2, |
||
67 | 'label' => '[+]Yml file name: ', |
||
68 | 'value' => array(), |
||
69 | 'name' => '[+]Plese enter yml file name', |
||
70 | 'validation' => array( |
||
71 | 'isRequired' => false, |
||
72 | 'inArray' => 'getYamlList', |
||
73 | ) |
||
74 | ), |
||
75 | 'supportFlag' => array( |
||
76 | 'no' => 3, |
||
77 | 'label' => '[+]Old version support: ', |
||
78 | 'value' => null, |
||
79 | 'name' => '[+]Do you want to support old versions too? [y/n]', |
||
80 | 'show' => array(1 => 'Yes', 0 => 'No'), |
||
81 | 'validation' => array( |
||
82 | 'isRequired' => true, |
||
83 | 'choice' => array('y' => 1, 'n' => 0), |
||
84 | ) |
||
85 | ) |
||
86 | ); |
||
87 | } |
||
88 | |||
89 | protected function getYamlList() |
||
90 | { |
||
91 | |||
92 | $pluginCode = $this->paramList['pluginCode']['value']; |
||
93 | |||
94 | if (!$pluginCode) { |
||
95 | return array(); |
||
96 | } |
||
97 | |||
98 | if ($this->ymlList === null) { |
||
99 | $this->ymlList = array(); |
||
100 | |||
101 | $finder = new Finder(); |
||
102 | $finder->files()->depth('== 0'); |
||
103 | $files = $finder->in($this->app['config']['root_dir'].'/app/Plugin/'.$pluginCode.'/Resource/doctrine/'); |
||
104 | |||
105 | foreach ($files as $item) { |
||
106 | $this->ymlList[$item->getFilename()] = $item->getRealPath(); |
||
107 | } |
||
108 | |||
0 ignored issues
–
show
|
|||
109 | } |
||
110 | |||
111 | return $this->ymlList; |
||
112 | } |
||
113 | |||
114 | protected function start() |
||
115 | { |
||
116 | $pluginCode = $this->paramList['pluginCode']['value']; |
||
117 | |||
118 | $codes = $this->getPluginCodes(); |
||
119 | if (!in_array($pluginCode, $codes)) { |
||
120 | $this->exitGenerator('<error>This plugin code does not exist.</error>'); |
||
121 | |||
122 | return; |
||
123 | } |
||
124 | |||
125 | $fsList = array( |
||
126 | 'dir' => array(), |
||
127 | 'file' => array(), |
||
128 | ); |
||
129 | |||
130 | $pluginCode = $this->paramList['pluginCode']['value']; |
||
131 | $ymlList = $this->paramList['ymlList']['value']; |
||
132 | |||
133 | $codePath = $this->app['config']['root_dir'].'/app/Plugin/'.$pluginCode; |
||
134 | |||
135 | $dirList = array('Entity', 'Repository', 'Resource/doctrine/migration'); |
||
136 | View Code Duplication | foreach ($dirList as $dirName) { |
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository.
Loading history...
|
|||
137 | $dirPath = $codePath.'/'.$dirName; |
||
138 | if (!is_dir($dirPath)) { |
||
139 | mkdir($dirPath); |
||
140 | } |
||
141 | if (is_dir($dirPath)) { |
||
142 | $fsList['dir'][$dirPath] = true; |
||
143 | } else { |
||
144 | $fsList['dir'][$dirPath] = false; |
||
145 | } |
||
146 | } |
||
147 | |||
148 | // metadataの設定 |
||
149 | $classNames = array(); |
||
150 | foreach ($ymlList as $item) { |
||
151 | $yml = Yaml::parse(file_get_contents($item)); |
||
152 | $classNames[] = key($yml); |
||
153 | } |
||
154 | |||
155 | $YamlDriver = new YamlDriver(array($codePath.'/Resource/doctrine')); |
||
156 | $metadatas = array(); |
||
157 | foreach ($classNames as $className) { |
||
158 | $ClassMetadataInfo = new ClassMetadataInfo($className); |
||
159 | $YamlDriver->loadMetadataForClass($className, $ClassMetadataInfo); |
||
160 | $metadatas[] = $ClassMetadataInfo; |
||
161 | } |
||
162 | |||
163 | // Entity、Repositoryファイルの作成 |
||
164 | $this->generateEntities($metadatas, $fsList); |
||
165 | |||
166 | // migrationファイルの作成 |
||
167 | $this->generateMigration($metadatas, $fsList, $pluginCode, $codePath); |
||
168 | |||
169 | // 完了メッセージ |
||
170 | $this->completeMessage($fsList); |
||
171 | |||
172 | } |
||
173 | } |
||
174 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.