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 Symfony\Component\Form\AbstractType; |
||
28 | use Symfony\Component\Form\Extension\Core\Type; |
||
29 | use Symfony\Component\Form\FormBuilderInterface; |
||
30 | use Symfony\Component\Form\FormError; |
||
31 | use Symfony\Component\Form\FormEvents; |
||
32 | use Symfony\Component\OptionsResolver\OptionsResolverInterface; |
||
33 | use Symfony\Component\Validator\Constraints as Assert; |
||
34 | |||
35 | class DeliveryType extends AbstractType |
||
36 | { |
||
37 | /** |
||
38 | * {@inheritdoc} |
||
39 | */ |
||
40 | 6 | public function buildForm(FormBuilderInterface $builder, array $options) |
|
41 | { |
||
42 | $builder |
||
43 | 6 | ->add('name', 'text', array( |
|
44 | 6 | 'label' => '配送業者名', |
|
45 | 'required' => true, |
||
46 | 'constraints' => array( |
||
47 | 6 | new Assert\NotBlank, |
|
48 | ), |
||
49 | )) |
||
50 | 6 | ->add('service_name', 'text', array( |
|
51 | 6 | 'label' => '名称', |
|
52 | 'required' => true, |
||
53 | 'constraints' => array( |
||
54 | 6 | new Assert\NotBlank(), |
|
55 | ), |
||
56 | )) |
||
57 | 6 | ->add('description', 'textarea', array( |
|
58 | 6 | 'label' => 'ショップ用メモ欄', |
|
59 | 'required' => false, |
||
60 | )) |
||
61 | 6 | ->add('confirm_url', 'text', array( |
|
62 | 6 | 'label' => '伝票No.URL', |
|
63 | 'required' => false, |
||
64 | 'constraints' => array( |
||
65 | 6 | new Assert\Url(), |
|
66 | ), |
||
67 | )) |
||
68 | 6 | ->add('product_type', 'product_type', array( |
|
69 | 'constraints' => array( |
||
70 | 6 | new Assert\NotBlank(), |
|
71 | ), |
||
72 | )) |
||
73 | // todo type paymentに変更 |
||
74 | 6 | ->add('payments', 'entity', array( |
|
75 | 6 | 'label' => '支払方法', |
|
76 | 6 | 'class' => 'Eccube\Entity\Payment', |
|
77 | 6 | 'property' => 'method', |
|
78 | 'expanded' => true, |
||
79 | 'multiple' => true, |
||
80 | 'required' => false, |
||
81 | 'query_builder' => function($er) { |
||
0 ignored issues
–
show
Coding Style
introduced
by
Loading history...
|
|||
82 | 6 | return $er->createQueryBuilder('p') |
|
83 | 6 | ->orderBy('p.rank', 'DESC'); |
|
84 | 6 | }, |
|
85 | 'mapped' => false, |
||
86 | )) |
||
87 | 6 | ->add('delivery_times', 'collection', array( |
|
88 | 6 | 'label' => 'お届け時間', |
|
89 | 'required' => false, |
||
90 | 'type' => 'delivery_time', |
||
91 | 'allow_add' => true, |
||
92 | 'allow_delete' => true, |
||
93 | 'prototype' => true, |
||
94 | )) |
||
95 | 6 | ->add('free_all', 'price', array( |
|
96 | 6 | 'label' => false, |
|
97 | 'currency' => 'JPY', |
||
98 | 'precision' => 0, |
||
99 | 'scale' => 0, |
||
100 | 'grouping' => true, |
||
101 | 'required' => false, |
||
102 | 'mapped' => false |
||
103 | )) |
||
104 | 6 | ->add('delivery_fees', 'collection', array( |
|
105 | 6 | 'label' => '都道府県別設定', |
|
106 | 'required' => true, |
||
107 | 'type' => 'delivery_fee', |
||
108 | 'allow_add' => true, |
||
109 | 'allow_delete' => true, |
||
110 | 'prototype' => true, |
||
111 | )) |
||
112 | 6 | ->addEventListener(FormEvents::POST_SUBMIT, function($event) { |
|
113 | 4 | $form = $event->getForm(); |
|
114 | 4 | $payments = $form['payments']->getData(); |
|
115 | |||
116 | 4 | if (empty($payments) || count($payments) < 1) { |
|
117 | $form['payments']->addError(new FormError('支払方法を選択してください。')); |
||
118 | } |
||
119 | 6 | }) |
|
120 | ; |
||
121 | } |
||
122 | |||
123 | /** |
||
124 | * {@inheritdoc} |
||
125 | */ |
||
126 | 6 | public function setDefaultOptions(OptionsResolverInterface $resolver) |
|
127 | { |
||
128 | 6 | $resolver->setDefaults(array( |
|
129 | 6 | 'data_class' => 'Eccube\Entity\Delivery', |
|
130 | )); |
||
131 | } |
||
132 | |||
133 | /** |
||
134 | * {@inheritdoc} |
||
135 | */ |
||
136 | 663 | public function getName() |
|
137 | { |
||
138 | 663 | return 'delivery'; |
|
139 | } |
||
140 | } |
||
141 |