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; |
||
26 | |||
27 | use Symfony\Component\Form\AbstractType; |
||
28 | use Symfony\Component\Form\FormBuilderInterface; |
||
29 | use Symfony\Component\Form\FormInterface; |
||
30 | use Symfony\Component\Form\FormView; |
||
31 | use Symfony\Component\OptionsResolver\OptionsResolverInterface; |
||
32 | use Symfony\Component\Validator\Constraints as Assert; |
||
33 | |||
34 | class NameType extends AbstractType |
||
35 | { |
||
36 | 304 | public function __construct($config = array('name_len' => 50)) |
|
37 | { |
||
38 | 304 | $this->config = $config; |
|
39 | 304 | } |
|
40 | |||
41 | /** |
||
42 | * {@inheritdoc} |
||
43 | */ |
||
44 | 26 | public function buildForm(FormBuilderInterface $builder, array $options) |
|
45 | { |
||
46 | 18 | $options['lastname_options']['required'] = $options['required']; |
|
47 | 18 | $options['firstname_options']['required'] = $options['required']; |
|
48 | |||
49 | // required の場合は NotBlank も追加する |
||
50 | 18 | if ($options['required']) { |
|
51 | 26 | $options['lastname_options']['constraints'] = array_merge(array( |
|
52 | new Assert\NotBlank(array()), |
||
53 | ), $options['lastname_options']['constraints']); |
||
54 | |||
55 | 26 | $options['firstname_options']['constraints'] = array_merge(array( |
|
56 | new Assert\NotBlank(array()), |
||
57 | ), $options['firstname_options']['constraints']); |
||
58 | } |
||
59 | |||
60 | 18 | View Code Duplication | if (!isset($options['options']['error_bubbling'])) { |
61 | 18 | $options['options']['error_bubbling'] = $options['error_bubbling']; |
|
62 | } |
||
63 | |||
64 | 18 | if (empty($options['lastname_name'])) { |
|
65 | $options['lastname_name'] = $builder->getName() . '01'; |
||
66 | } |
||
67 | 18 | if (empty($options['firstname_name'])) { |
|
68 | $options['firstname_name'] = $builder->getName() . '02'; |
||
69 | } |
||
70 | |||
71 | $builder |
||
72 | ->add($options['lastname_name'], 'text', array_merge_recursive($options['options'], $options['lastname_options'])) |
||
73 | ->add($options['firstname_name'], 'text', array_merge_recursive($options['options'], $options['firstname_options'])) |
||
74 | 18 | ; |
|
75 | |||
76 | $builder->setAttribute('lastname_name', $options['lastname_name']); |
||
77 | $builder->setAttribute('firstname_name', $options['firstname_name']); |
||
78 | } |
||
79 | |||
80 | /** |
||
81 | * {@inheritdoc} |
||
82 | */ |
||
83 | public function buildView(FormView $view, FormInterface $form, array $options) |
||
84 | { |
||
85 | $builder = $form->getConfig(); |
||
86 | $view->vars['lastname_name'] = $builder->getAttribute('lastname_name'); |
||
87 | $view->vars['firstname_name'] = $builder->getAttribute('firstname_name'); |
||
88 | } |
||
89 | |||
90 | /** |
||
91 | * {@inheritdoc} |
||
92 | */ |
||
93 | public function setDefaultOptions(OptionsResolverInterface $resolver) |
||
94 | 109 | { |
|
95 | $resolver->setDefaults(array( |
||
96 | 'options' => array(), |
||
97 | 109 | 'lastname_options' => array( |
|
98 | 'attr' => array( |
||
99 | 'placeholder' => 'Name01', |
||
100 | ), |
||
101 | 109 | 'constraints' => array( |
|
102 | new Assert\Length(array( |
||
103 | 'max' => $this->config['name_len'], |
||
104 | 109 | )), |
|
105 | new Assert\Regex(array( |
||
0 ignored issues
–
show
introduced
by
Loading history...
|
|||
106 | 'pattern' => '/^[^\s ]+$/u', |
||
107 | 'message' => 'form.type.name.firstname.nothasspace' |
||
108 | )) |
||
109 | ), |
||
110 | 109 | ), |
|
111 | 109 | 'firstname_options' => array( |
|
112 | 'attr' => array( |
||
113 | 'placeholder' => 'Name02', |
||
114 | ), |
||
115 | 109 | 'constraints' => array( |
|
116 | new Assert\Length(array( |
||
117 | 'max' => $this->config['name_len'], |
||
118 | 109 | )), |
|
119 | new Assert\Regex(array( |
||
0 ignored issues
–
show
|
|||
120 | 'pattern' => '/^[^\s ]+$/u', |
||
121 | 'message' => 'form.type.name.lastname.nothasspace' |
||
122 | )) |
||
123 | ), |
||
124 | 109 | ), |
|
125 | 109 | 'lastname_name' => '', |
|
126 | 109 | 'firstname_name' => '', |
|
127 | 109 | 'error_bubbling' => false, |
|
128 | 109 | 'inherit_data' => true, |
|
129 | 109 | 'trim' => true, |
|
130 | 109 | )); |
|
131 | } |
||
132 | |||
133 | /** |
||
134 | * {@inheritdoc} |
||
135 | */ |
||
136 | public function getName() |
||
137 | 195 | { |
|
138 | return 'name'; |
||
139 | 195 | } |
|
140 | } |
||
141 |