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 | namespace DoctrineMigrations; |
||
3 | |||
4 | use Doctrine\DBAL\Migrations\AbstractMigration; |
||
5 | use Doctrine\DBAL\Schema\Schema; |
||
6 | use Doctrine\ORM\EntityManager; |
||
7 | use Eccube\Application; |
||
8 | use Eccube\Common\Constant; |
||
9 | use Eccube\Entity\Csv; |
||
10 | use Eccube\Entity\Master\CsvType; |
||
11 | use Eccube\Entity\Master\Tag; |
||
12 | |||
13 | /** |
||
14 | * Auto-generated Migration: Please modify to your needs! |
||
15 | */ |
||
16 | class Version20160114142234 extends AbstractMigration |
||
17 | { |
||
18 | private $tag_datas = array( |
||
19 | array( |
||
20 | 'id' => 1, |
||
21 | 'name' => '新商品', |
||
22 | 'rank' => 1, |
||
23 | ), |
||
24 | array( |
||
25 | 'id' => 2, |
||
26 | 'name' => 'おすすめ商品', |
||
27 | 'rank' => 2, |
||
28 | ), |
||
29 | array( |
||
30 | 'id' => 3, |
||
31 | 'name' => '限定品', |
||
32 | 'rank' => 3, |
||
33 | ), |
||
34 | ); |
||
35 | |||
36 | private $csv_datas = array( |
||
37 | array( |
||
38 | 'entity_name' => 'Eccube\\\\Entity\\\\Product', |
||
39 | 'field_name' => 'ProductTag', |
||
40 | 'reference_field_name' => 'tag_id', |
||
41 | 'disp_name' => 'タグ(ID)', |
||
42 | ), |
||
43 | array( |
||
44 | 'entity_name' => 'Eccube\\\\Entity\\\\Product', |
||
45 | 'field_name' => 'ProductTag', |
||
46 | 'reference_field_name' => 'Tag', |
||
47 | 'disp_name' => 'タグ(名称)', |
||
48 | ), |
||
49 | ); |
||
50 | |||
51 | /** |
||
52 | * @param Schema $schema |
||
53 | */ |
||
54 | public function up(Schema $schema) |
||
55 | { |
||
56 | $app = \Eccube\Application::getInstance(); |
||
57 | $em = $app['orm.em']; |
||
58 | |||
59 | $this->mtb_tag($em); |
||
60 | $this->dtb_csv($em); |
||
61 | |||
62 | $em->flush(); |
||
63 | } |
||
64 | |||
65 | /** |
||
66 | * @param Schema $schema |
||
67 | */ |
||
68 | public function down(Schema $schema) |
||
69 | { |
||
70 | $app = \Eccube\Application::getInstance(); |
||
71 | $em = $app['orm.em']; |
||
72 | |||
73 | $this->delete_dtb_csv($em); |
||
74 | |||
75 | $em->flush(); |
||
76 | } |
||
77 | |||
78 | /** |
||
79 | * insert mtb_tag |
||
80 | * |
||
81 | * @param EntityManager $em |
||
82 | */ |
||
83 | private function mtb_tag(EntityManager $em) |
||
0 ignored issues
–
show
Coding Style
introduced
by
Loading history...
|
|||
84 | { |
||
85 | $Tags = $em->getRepository('\Eccube\Entity\Master\Tag')->findAll(); |
||
86 | if (0 < count($Tags)) { |
||
87 | // すでに使用している場合は登録しない。 |
||
88 | return; |
||
89 | } |
||
90 | |||
91 | foreach ($this->tag_datas as $data) { |
||
92 | $Tag = new Tag(); |
||
93 | $Tag |
||
94 | ->setId($data['id']) |
||
95 | ->setName($data['name']) |
||
96 | ->setRank($data['rank']); |
||
97 | |||
98 | $em->persist($Tag); |
||
99 | } |
||
100 | } |
||
101 | |||
102 | /** |
||
103 | * insert dtb_csv |
||
104 | * |
||
105 | * @param EntityManager $em |
||
106 | */ |
||
107 | private function dtb_csv(EntityManager $em) |
||
0 ignored issues
–
show
|
|||
108 | { |
||
109 | $filter = $em->getFilters()->getFilter('soft_delete'); |
||
110 | $filter->setExcludes(array( |
||
111 | 'Eccube\Entity\Member' |
||
112 | )); |
||
113 | $CsvType = $em->getRepository('Eccube\Entity\Master\CsvType')->find(CsvType::CSV_TYPE_PRODUCT); |
||
114 | $Member = $em->getRepository('Eccube\Entity\Member')->find(1); |
||
115 | $Csv = $em->getRepository('Eccube\Entity\Csv')->findOneBy( |
||
116 | array('CsvType' => $CsvType), |
||
117 | array('rank' => 'DESC') |
||
118 | ); |
||
119 | $rank = $Csv->getRank(); |
||
120 | |||
121 | foreach ($this->csv_datas as $data) { |
||
122 | $rank++; |
||
123 | |||
124 | $Csv = new Csv(); |
||
125 | $Csv |
||
126 | ->setCsvType($CsvType) |
||
127 | ->setCreator($Member) |
||
128 | ->setEntityName($data['entity_name']) |
||
129 | ->setFieldName($data['field_name']) |
||
130 | ->setReferenceFieldName($data['reference_field_name']) |
||
131 | ->setDispName($data['disp_name']) |
||
132 | ->setRank($rank) |
||
133 | ->setEnableFlg(Constant::ENABLED); |
||
134 | |||
135 | $em->persist($Csv); |
||
136 | } |
||
137 | } |
||
138 | |||
139 | /** |
||
140 | * delete dtb_csv |
||
141 | * |
||
142 | * @param EntityManager $em |
||
143 | */ |
||
144 | private function delete_dtb_csv(EntityManager $em) |
||
0 ignored issues
–
show
|
|||
145 | { |
||
146 | $repository = $em->getRepository('Eccube\Entity\Csv'); |
||
147 | foreach ($this->csv_datas as $data) { |
||
148 | $Csv = $repository->findOneBy(array( |
||
149 | 'entity_name' => $data['entity_name'], |
||
150 | 'field_name' => $data['field_name'], |
||
151 | 'reference_field_name' => $data['reference_field_name'], |
||
152 | )); |
||
153 | |||
154 | if ($Csv) { |
||
155 | $em->remove($Csv); |
||
156 | } |
||
157 | } |
||
158 | } |
||
159 | } |
||
160 |