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 | * This file is part of EC-CUBE |
||
4 | * |
||
5 | * Copyright(c) 2000-2015 LOCKON CO.,LTD. All Rights Reserved. |
||
6 | * |
||
7 | * http://www.lockon.co.jp/ |
||
8 | * |
||
9 | * This program is free software; you can redistribute it and/or |
||
10 | * modify it under the terms of the GNU General Public License |
||
11 | * as published by the Free Software Foundation; either version 2 |
||
12 | * of the License, or (at your option) any later version. |
||
13 | * |
||
14 | * This program is distributed in the hope that it will be useful, |
||
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
17 | * GNU General Public License for more details. |
||
18 | * |
||
19 | * You should have received a copy of the GNU General Public License |
||
20 | * along with this program; if not, write to the Free Software |
||
21 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
||
22 | */ |
||
23 | |||
24 | |||
25 | namespace Eccube\Form\Type\Admin; |
||
26 | |||
27 | use Eccube\Form\DataTransformer; |
||
28 | use Symfony\Component\Form\AbstractType; |
||
29 | use Symfony\Component\Form\Extension\Core\Type; |
||
30 | use Symfony\Component\Form\FormBuilderInterface; |
||
31 | use Symfony\Component\Form\FormError; |
||
32 | use Symfony\Component\Form\FormEvents; |
||
33 | use Symfony\Component\OptionsResolver\OptionsResolverInterface; |
||
34 | use Symfony\Component\Validator\Constraints as Assert; |
||
35 | |||
36 | class ProductClassType extends AbstractType |
||
37 | { |
||
38 | public $app; |
||
39 | |||
40 | 663 | public function __construct(\Silex\Application $app) |
|
41 | { |
||
42 | 663 | $this->app = $app; |
|
43 | } |
||
44 | |||
45 | /** |
||
46 | * {@inheritdoc} |
||
47 | */ |
||
48 | 47 | public function buildForm(FormBuilderInterface $builder, array $options) |
|
49 | { |
||
50 | 47 | $app = $this->app; |
|
51 | |||
52 | $builder |
||
53 | 47 | ->add('code', 'text', array( |
|
54 | 47 | 'label' => '商品コード', |
|
55 | 'required' => false, |
||
56 | )) |
||
57 | 47 | ->add('stock', 'number', array( |
|
58 | 47 | 'label' => '在庫数', |
|
59 | 'required' => false, |
||
60 | 'constraints' => array( |
||
61 | 47 | new Assert\Regex(array( |
|
0 ignored issues
–
show
introduced
by
Loading history...
|
|||
62 | 47 | 'pattern' => "/^\d+$/u", |
|
63 | 'message' => 'form.type.numeric.invalid' |
||
64 | )), |
||
65 | ), |
||
66 | )) |
||
67 | 47 | ->add('sale_limit', 'number', array( |
|
68 | 47 | 'label' => '販売制限数', |
|
69 | 'required' => false, |
||
70 | 'constraints' => array( |
||
71 | 47 | new Assert\Length(array( |
|
72 | 47 | 'max' => 10, |
|
73 | )), |
||
74 | 47 | new Assert\GreaterThanOrEqual(array( |
|
75 | 47 | 'value' => 1, |
|
76 | )), |
||
77 | 47 | new Assert\Regex(array( |
|
0 ignored issues
–
show
|
|||
78 | 47 | 'pattern' => "/^\d+$/u", |
|
79 | 'message' => 'form.type.numeric.invalid' |
||
80 | )), |
||
81 | ), |
||
82 | )) |
||
83 | 47 | ->add('price01', 'money', array( |
|
84 | 47 | 'label' => '通常価格', |
|
85 | 47 | 'currency' => 'JPY', |
|
86 | 47 | 'precision' => 0, |
|
87 | 47 | 'scale' => 0, |
|
88 | 'grouping' => true, |
||
89 | 'required' => false, |
||
90 | 'constraints' => array( |
||
91 | 47 | new Assert\Length(array( |
|
92 | 47 | 'max' => 10, |
|
93 | )), |
||
94 | 47 | new Assert\Regex(array( |
|
0 ignored issues
–
show
|
|||
95 | 47 | 'pattern' => "/^\d+$/u", |
|
96 | 'message' => 'form.type.numeric.invalid' |
||
97 | )), |
||
98 | ), |
||
99 | )) |
||
100 | 47 | ->add('price02', 'money', array( |
|
101 | 47 | 'label' => '販売価格', |
|
102 | 47 | 'currency' => 'JPY', |
|
103 | 47 | 'precision' => 0, |
|
104 | 47 | 'scale' => 0, |
|
105 | 'grouping' => true, |
||
106 | 'constraints' => array( |
||
107 | 47 | new Assert\NotBlank(), |
|
108 | 47 | new Assert\Length(array( |
|
109 | 47 | 'max' => 10, |
|
110 | )), |
||
111 | 47 | new Assert\Regex(array( |
|
0 ignored issues
–
show
|
|||
112 | 47 | 'pattern' => "/^\d+$/u", |
|
113 | 'message' => 'form.type.numeric.invalid' |
||
114 | )), |
||
115 | ), |
||
116 | )) |
||
117 | 47 | ->add('tax_rate', 'text', array( |
|
118 | 47 | 'label' => '消費税率', |
|
119 | 'required' => false, |
||
120 | 'constraints' => array( |
||
121 | 47 | new Assert\Range(array('min' => 0, 'max' => 100)), |
|
122 | 47 | new Assert\Regex(array( |
|
0 ignored issues
–
show
|
|||
123 | 47 | 'pattern' => "/^\d+(\.\d+)?$/", |
|
124 | 'message' => 'form.type.float.invalid' |
||
125 | )), |
||
126 | ), |
||
127 | )) |
||
128 | 47 | ->add('delivery_fee', 'money', array( |
|
129 | 47 | 'label' => '商品送料', |
|
130 | 47 | 'currency' => 'JPY', |
|
131 | 47 | 'precision' => 0, |
|
132 | 47 | 'scale' => 0, |
|
133 | 'grouping' => true, |
||
134 | 'required' => false, |
||
135 | 'constraints' => array( |
||
136 | 47 | new Assert\Regex(array( |
|
0 ignored issues
–
show
|
|||
137 | 47 | 'pattern' => "/^\d+$/u", |
|
138 | 'message' => 'form.type.numeric.invalid' |
||
139 | )), |
||
140 | ), |
||
141 | )) |
||
142 | 47 | ->add('product_type', 'product_type', array( |
|
143 | 47 | 'label' => '商品種別', |
|
144 | 'multiple' => false, |
||
145 | 'expanded' => false, |
||
146 | 'constraints' => array( |
||
147 | 47 | new Assert\NotBlank(), |
|
148 | ), |
||
149 | )) |
||
150 | 47 | ->add('delivery_date', 'delivery_date', array( |
|
151 | 47 | 'label' => 'お届け可能日', |
|
152 | 'required' => false, |
||
153 | 'empty_value' => '指定なし', |
||
154 | )) |
||
155 | 47 | ->add('add', 'checkbox', array( |
|
156 | 47 | 'label' => false, |
|
157 | 'required' => false, |
||
158 | 'value' => 1, |
||
159 | )) |
||
160 | 47 | ->addEventListener(FormEvents::POST_SUBMIT, function ($event) { |
|
161 | 42 | $form = $event->getForm(); |
|
162 | 42 | $data = $form->getData(); |
|
163 | |||
164 | 42 | if (empty($data['stock_unlimited']) && is_null($data['stock'])) { |
|
165 | 1 | $form['stock_unlimited']->addError(new FormError('在庫数を入力、もしくは在庫無制限を設定してください。')); |
|
166 | } |
||
167 | 47 | }); |
|
168 | |||
169 | 47 | $transformer = new DataTransformer\IntegerToBooleanTransformer(); |
|
170 | |||
171 | $builder |
||
172 | 47 | ->add($builder->create('stock_unlimited', 'checkbox', array( |
|
173 | 47 | 'label' => '無制限', |
|
174 | 'value' => '1', |
||
175 | 'required' => false, |
||
176 | 47 | ))->addModelTransformer($transformer)); |
|
177 | |||
178 | |||
179 | 47 | $transformer = new DataTransformer\EntityToIdTransformer( |
|
180 | 47 | $app['orm.em'], |
|
181 | 47 | '\Eccube\Entity\ClassCategory' |
|
182 | ); |
||
183 | $builder |
||
184 | 47 | ->add($builder->create('ClassCategory1', 'hidden') |
|
185 | 47 | ->addModelTransformer($transformer) |
|
186 | ) |
||
187 | 47 | ->add($builder->create('ClassCategory2', 'hidden') |
|
188 | 47 | ->addModelTransformer($transformer) |
|
189 | ); |
||
190 | } |
||
191 | |||
192 | /** |
||
193 | * {@inheritdoc} |
||
194 | */ |
||
195 | 47 | public function setDefaultOptions(OptionsResolverInterface $resolver) |
|
196 | { |
||
197 | 47 | $resolver->setDefaults(array( |
|
198 | 47 | 'data_class' => 'Eccube\Entity\ProductClass', |
|
199 | )); |
||
200 | } |
||
201 | |||
202 | /** |
||
203 | * {@inheritdoc} |
||
204 | */ |
||
205 | 663 | public function getName() |
|
206 | { |
||
207 | 663 | return 'admin_product_class'; |
|
208 | } |
||
209 | } |
||
210 |