diff options
Diffstat (limited to 'vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type')
31 files changed, 2785 insertions, 0 deletions
diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/BaseType.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/BaseType.php new file mode 100644 index 00000000..79333a67 --- /dev/null +++ b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/BaseType.php | |||
@@ -0,0 +1,121 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Extension\Core\Type; | ||
13 | |||
14 | use Symfony\Component\Form\AbstractType; | ||
15 | use Symfony\Component\Form\FormBuilderInterface; | ||
16 | use Symfony\Component\Form\FormInterface; | ||
17 | use Symfony\Component\Form\FormView; | ||
18 | use Symfony\Component\OptionsResolver\OptionsResolverInterface; | ||
19 | |||
20 | /** | ||
21 | * Encapsulates common logic of {@link FormType} and {@link ButtonType}. | ||
22 | * | ||
23 | * This type does not appear in the form's type inheritance chain and as such | ||
24 | * cannot be extended (via {@link FormTypeExtension}s) nor themed. | ||
25 | * | ||
26 | * @author Bernhard Schussek <bschussek@gmail.com> | ||
27 | */ | ||
28 | abstract class BaseType extends AbstractType | ||
29 | { | ||
30 | /** | ||
31 | * {@inheritdoc} | ||
32 | */ | ||
33 | public function buildForm(FormBuilderInterface $builder, array $options) | ||
34 | { | ||
35 | $builder->setDisabled($options['disabled']); | ||
36 | } | ||
37 | |||
38 | /** | ||
39 | * {@inheritdoc} | ||
40 | */ | ||
41 | public function buildView(FormView $view, FormInterface $form, array $options) | ||
42 | { | ||
43 | $name = $form->getName(); | ||
44 | $blockName = $options['block_name'] ?: $form->getName(); | ||
45 | $translationDomain = $options['translation_domain']; | ||
46 | |||
47 | if ($view->parent) { | ||
48 | if ('' !== ($parentFullName = $view->parent->vars['full_name'])) { | ||
49 | $id = sprintf('%s_%s', $view->parent->vars['id'], $name); | ||
50 | $fullName = sprintf('%s[%s]', $parentFullName, $name); | ||
51 | $uniqueBlockPrefix = sprintf('%s_%s', $view->parent->vars['unique_block_prefix'], $blockName); | ||
52 | } else { | ||
53 | $id = $name; | ||
54 | $fullName = $name; | ||
55 | $uniqueBlockPrefix = '_'.$blockName; | ||
56 | } | ||
57 | |||
58 | if (!$translationDomain) { | ||
59 | $translationDomain = $view->parent->vars['translation_domain']; | ||
60 | } | ||
61 | } else { | ||
62 | $id = $name; | ||
63 | $fullName = $name; | ||
64 | $uniqueBlockPrefix = '_'.$blockName; | ||
65 | |||
66 | // Strip leading underscores and digits. These are allowed in | ||
67 | // form names, but not in HTML4 ID attributes. | ||
68 | // http://www.w3.org/TR/html401/struct/global.html#adef-id | ||
69 | $id = ltrim($id, '_0123456789'); | ||
70 | } | ||
71 | |||
72 | $blockPrefixes = array(); | ||
73 | for ($type = $form->getConfig()->getType(); null !== $type; $type = $type->getParent()) { | ||
74 | array_unshift($blockPrefixes, $type->getName()); | ||
75 | } | ||
76 | $blockPrefixes[] = $uniqueBlockPrefix; | ||
77 | |||
78 | if (!$translationDomain) { | ||
79 | $translationDomain = 'messages'; | ||
80 | } | ||
81 | |||
82 | $view->vars = array_replace($view->vars, array( | ||
83 | 'form' => $view, | ||
84 | 'id' => $id, | ||
85 | 'name' => $name, | ||
86 | 'full_name' => $fullName, | ||
87 | 'disabled' => $form->isDisabled(), | ||
88 | 'label' => $options['label'], | ||
89 | 'multipart' => false, | ||
90 | 'attr' => $options['attr'], | ||
91 | 'block_prefixes' => $blockPrefixes, | ||
92 | 'unique_block_prefix' => $uniqueBlockPrefix, | ||
93 | 'translation_domain' => $translationDomain, | ||
94 | // Using the block name here speeds up performance in collection | ||
95 | // forms, where each entry has the same full block name. | ||
96 | // Including the type is important too, because if rows of a | ||
97 | // collection form have different types (dynamically), they should | ||
98 | // be rendered differently. | ||
99 | // https://github.com/symfony/symfony/issues/5038 | ||
100 | 'cache_key' => $uniqueBlockPrefix.'_'.$form->getConfig()->getType()->getName(), | ||
101 | )); | ||
102 | } | ||
103 | |||
104 | /** | ||
105 | * {@inheritdoc} | ||
106 | */ | ||
107 | public function setDefaultOptions(OptionsResolverInterface $resolver) | ||
108 | { | ||
109 | $resolver->setDefaults(array( | ||
110 | 'block_name' => null, | ||
111 | 'disabled' => false, | ||
112 | 'label' => null, | ||
113 | 'attr' => array(), | ||
114 | 'translation_domain' => null, | ||
115 | )); | ||
116 | |||
117 | $resolver->setAllowedTypes(array( | ||
118 | 'attr' => 'array', | ||
119 | )); | ||
120 | } | ||
121 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/BirthdayType.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/BirthdayType.php new file mode 100644 index 00000000..5314c140 --- /dev/null +++ b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/BirthdayType.php | |||
@@ -0,0 +1,44 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Extension\Core\Type; | ||
13 | |||
14 | use Symfony\Component\Form\AbstractType; | ||
15 | use Symfony\Component\OptionsResolver\OptionsResolverInterface; | ||
16 | |||
17 | class BirthdayType extends AbstractType | ||
18 | { | ||
19 | /** | ||
20 | * {@inheritdoc} | ||
21 | */ | ||
22 | public function setDefaultOptions(OptionsResolverInterface $resolver) | ||
23 | { | ||
24 | $resolver->setDefaults(array( | ||
25 | 'years' => range(date('Y') - 120, date('Y')), | ||
26 | )); | ||
27 | } | ||
28 | |||
29 | /** | ||
30 | * {@inheritdoc} | ||
31 | */ | ||
32 | public function getParent() | ||
33 | { | ||
34 | return 'date'; | ||
35 | } | ||
36 | |||
37 | /** | ||
38 | * {@inheritdoc} | ||
39 | */ | ||
40 | public function getName() | ||
41 | { | ||
42 | return 'birthday'; | ||
43 | } | ||
44 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/ButtonType.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/ButtonType.php new file mode 100644 index 00000000..3569963b --- /dev/null +++ b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/ButtonType.php | |||
@@ -0,0 +1,38 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Extension\Core\Type; | ||
13 | |||
14 | use Symfony\Component\Form\ButtonTypeInterface; | ||
15 | |||
16 | /** | ||
17 | * A form button. | ||
18 | * | ||
19 | * @author Bernhard Schussek <bschussek@gmail.com> | ||
20 | */ | ||
21 | class ButtonType extends BaseType implements ButtonTypeInterface | ||
22 | { | ||
23 | /** | ||
24 | * {@inheritdoc} | ||
25 | */ | ||
26 | public function getParent() | ||
27 | { | ||
28 | return null; | ||
29 | } | ||
30 | |||
31 | /** | ||
32 | * {@inheritdoc} | ||
33 | */ | ||
34 | public function getName() | ||
35 | { | ||
36 | return 'button'; | ||
37 | } | ||
38 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/CheckboxType.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/CheckboxType.php new file mode 100644 index 00000000..214e581a --- /dev/null +++ b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/CheckboxType.php | |||
@@ -0,0 +1,67 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Extension\Core\Type; | ||
13 | |||
14 | use Symfony\Component\Form\AbstractType; | ||
15 | use Symfony\Component\Form\FormBuilderInterface; | ||
16 | use Symfony\Component\Form\FormInterface; | ||
17 | use Symfony\Component\Form\Extension\Core\DataTransformer\BooleanToStringTransformer; | ||
18 | use Symfony\Component\Form\FormView; | ||
19 | use Symfony\Component\OptionsResolver\OptionsResolverInterface; | ||
20 | |||
21 | class CheckboxType extends AbstractType | ||
22 | { | ||
23 | /** | ||
24 | * {@inheritdoc} | ||
25 | */ | ||
26 | public function buildForm(FormBuilderInterface $builder, array $options) | ||
27 | { | ||
28 | $builder | ||
29 | ->addViewTransformer(new BooleanToStringTransformer($options['value'])) | ||
30 | ; | ||
31 | } | ||
32 | |||
33 | /** | ||
34 | * {@inheritdoc} | ||
35 | */ | ||
36 | public function buildView(FormView $view, FormInterface $form, array $options) | ||
37 | { | ||
38 | $view->vars = array_replace($view->vars, array( | ||
39 | 'value' => $options['value'], | ||
40 | 'checked' => null !== $form->getViewData(), | ||
41 | )); | ||
42 | } | ||
43 | |||
44 | /** | ||
45 | * {@inheritdoc} | ||
46 | */ | ||
47 | public function setDefaultOptions(OptionsResolverInterface $resolver) | ||
48 | { | ||
49 | $emptyData = function (FormInterface $form, $clientData) { | ||
50 | return $clientData; | ||
51 | }; | ||
52 | |||
53 | $resolver->setDefaults(array( | ||
54 | 'value' => '1', | ||
55 | 'empty_data' => $emptyData, | ||
56 | 'compound' => false, | ||
57 | )); | ||
58 | } | ||
59 | |||
60 | /** | ||
61 | * {@inheritdoc} | ||
62 | */ | ||
63 | public function getName() | ||
64 | { | ||
65 | return 'checkbox'; | ||
66 | } | ||
67 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php new file mode 100644 index 00000000..9a3fdef1 --- /dev/null +++ b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php | |||
@@ -0,0 +1,274 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Extension\Core\Type; | ||
13 | |||
14 | use Symfony\Component\Form\AbstractType; | ||
15 | use Symfony\Component\Form\Extension\Core\View\ChoiceView; | ||
16 | use Symfony\Component\Form\FormBuilderInterface; | ||
17 | use Symfony\Component\Form\FormInterface; | ||
18 | use Symfony\Component\Form\FormView; | ||
19 | use Symfony\Component\Form\Exception\LogicException; | ||
20 | use Symfony\Component\Form\Extension\Core\ChoiceList\SimpleChoiceList; | ||
21 | use Symfony\Component\Form\Extension\Core\EventListener\FixRadioInputListener; | ||
22 | use Symfony\Component\Form\Extension\Core\EventListener\FixCheckboxInputListener; | ||
23 | use Symfony\Component\Form\Extension\Core\EventListener\MergeCollectionListener; | ||
24 | use Symfony\Component\Form\Extension\Core\DataTransformer\ChoiceToValueTransformer; | ||
25 | use Symfony\Component\Form\Extension\Core\DataTransformer\ChoiceToBooleanArrayTransformer; | ||
26 | use Symfony\Component\Form\Extension\Core\DataTransformer\ChoicesToValuesTransformer; | ||
27 | use Symfony\Component\Form\Extension\Core\DataTransformer\ChoicesToBooleanArrayTransformer; | ||
28 | use Symfony\Component\OptionsResolver\Options; | ||
29 | use Symfony\Component\OptionsResolver\OptionsResolverInterface; | ||
30 | |||
31 | class ChoiceType extends AbstractType | ||
32 | { | ||
33 | /** | ||
34 | * Caches created choice lists. | ||
35 | * @var array | ||
36 | */ | ||
37 | private $choiceListCache = array(); | ||
38 | |||
39 | /** | ||
40 | * {@inheritdoc} | ||
41 | */ | ||
42 | public function buildForm(FormBuilderInterface $builder, array $options) | ||
43 | { | ||
44 | if (!$options['choice_list'] && !is_array($options['choices']) && !$options['choices'] instanceof \Traversable) { | ||
45 | throw new LogicException('Either the option "choices" or "choice_list" must be set.'); | ||
46 | } | ||
47 | |||
48 | if ($options['expanded']) { | ||
49 | // Initialize all choices before doing the index check below. | ||
50 | // This helps in cases where index checks are optimized for non | ||
51 | // initialized choice lists. For example, when using an SQL driver, | ||
52 | // the index check would read in one SQL query and the initialization | ||
53 | // requires another SQL query. When the initialization is done first, | ||
54 | // one SQL query is sufficient. | ||
55 | $preferredViews = $options['choice_list']->getPreferredViews(); | ||
56 | $remainingViews = $options['choice_list']->getRemainingViews(); | ||
57 | |||
58 | // Check if the choices already contain the empty value | ||
59 | // Only add the empty value option if this is not the case | ||
60 | if (null !== $options['empty_value'] && 0 === count($options['choice_list']->getIndicesForValues(array('')))) { | ||
61 | $placeholderView = new ChoiceView(null, '', $options['empty_value']); | ||
62 | |||
63 | // "placeholder" is a reserved index | ||
64 | // see also ChoiceListInterface::getIndicesForChoices() | ||
65 | $this->addSubForms($builder, array('placeholder' => $placeholderView), $options); | ||
66 | } | ||
67 | |||
68 | $this->addSubForms($builder, $preferredViews, $options); | ||
69 | $this->addSubForms($builder, $remainingViews, $options); | ||
70 | |||
71 | if ($options['multiple']) { | ||
72 | $builder->addViewTransformer(new ChoicesToBooleanArrayTransformer($options['choice_list'])); | ||
73 | $builder->addEventSubscriber(new FixCheckboxInputListener($options['choice_list']), 10); | ||
74 | } else { | ||
75 | $builder->addViewTransformer(new ChoiceToBooleanArrayTransformer($options['choice_list'], $builder->has('placeholder'))); | ||
76 | $builder->addEventSubscriber(new FixRadioInputListener($options['choice_list'], $builder->has('placeholder')), 10); | ||
77 | } | ||
78 | } else { | ||
79 | if ($options['multiple']) { | ||
80 | $builder->addViewTransformer(new ChoicesToValuesTransformer($options['choice_list'])); | ||
81 | } else { | ||
82 | $builder->addViewTransformer(new ChoiceToValueTransformer($options['choice_list'])); | ||
83 | } | ||
84 | } | ||
85 | |||
86 | if ($options['multiple'] && $options['by_reference']) { | ||
87 | // Make sure the collection created during the client->norm | ||
88 | // transformation is merged back into the original collection | ||
89 | $builder->addEventSubscriber(new MergeCollectionListener(true, true)); | ||
90 | } | ||
91 | } | ||
92 | |||
93 | /** | ||
94 | * {@inheritdoc} | ||
95 | */ | ||
96 | public function buildView(FormView $view, FormInterface $form, array $options) | ||
97 | { | ||
98 | $view->vars = array_replace($view->vars, array( | ||
99 | 'multiple' => $options['multiple'], | ||
100 | 'expanded' => $options['expanded'], | ||
101 | 'preferred_choices' => $options['choice_list']->getPreferredViews(), | ||
102 | 'choices' => $options['choice_list']->getRemainingViews(), | ||
103 | 'separator' => '-------------------', | ||
104 | 'empty_value' => null, | ||
105 | )); | ||
106 | |||
107 | // The decision, whether a choice is selected, is potentially done | ||
108 | // thousand of times during the rendering of a template. Provide a | ||
109 | // closure here that is optimized for the value of the form, to | ||
110 | // avoid making the type check inside the closure. | ||
111 | if ($options['multiple']) { | ||
112 | $view->vars['is_selected'] = function ($choice, array $values) { | ||
113 | return false !== array_search($choice, $values, true); | ||
114 | }; | ||
115 | } else { | ||
116 | $view->vars['is_selected'] = function ($choice, $value) { | ||
117 | return $choice === $value; | ||
118 | }; | ||
119 | } | ||
120 | |||
121 | // Check if the choices already contain the empty value | ||
122 | // Only add the empty value option if this is not the case | ||
123 | if (null !== $options['empty_value'] && 0 === count($options['choice_list']->getIndicesForValues(array('')))) { | ||
124 | $view->vars['empty_value'] = $options['empty_value']; | ||
125 | } | ||
126 | |||
127 | if ($options['multiple'] && !$options['expanded']) { | ||
128 | // Add "[]" to the name in case a select tag with multiple options is | ||
129 | // displayed. Otherwise only one of the selected options is sent in the | ||
130 | // POST request. | ||
131 | $view->vars['full_name'] = $view->vars['full_name'].'[]'; | ||
132 | } | ||
133 | } | ||
134 | |||
135 | /** | ||
136 | * {@inheritdoc} | ||
137 | */ | ||
138 | public function finishView(FormView $view, FormInterface $form, array $options) | ||
139 | { | ||
140 | if ($options['expanded']) { | ||
141 | // Radio buttons should have the same name as the parent | ||
142 | $childName = $view->vars['full_name']; | ||
143 | |||
144 | // Checkboxes should append "[]" to allow multiple selection | ||
145 | if ($options['multiple']) { | ||
146 | $childName .= '[]'; | ||
147 | } | ||
148 | |||
149 | foreach ($view as $childView) { | ||
150 | $childView->vars['full_name'] = $childName; | ||
151 | } | ||
152 | } | ||
153 | } | ||
154 | |||
155 | /** | ||
156 | * {@inheritdoc} | ||
157 | */ | ||
158 | public function setDefaultOptions(OptionsResolverInterface $resolver) | ||
159 | { | ||
160 | $choiceListCache =& $this->choiceListCache; | ||
161 | |||
162 | $choiceList = function (Options $options) use (&$choiceListCache) { | ||
163 | // Harden against NULL values (like in EntityType and ModelType) | ||
164 | $choices = null !== $options['choices'] ? $options['choices'] : array(); | ||
165 | |||
166 | // Reuse existing choice lists in order to increase performance | ||
167 | $hash = md5(json_encode(array($choices, $options['preferred_choices']))); | ||
168 | |||
169 | if (!isset($choiceListCache[$hash])) { | ||
170 | $choiceListCache[$hash] = new SimpleChoiceList($choices, $options['preferred_choices']); | ||
171 | } | ||
172 | |||
173 | return $choiceListCache[$hash]; | ||
174 | }; | ||
175 | |||
176 | $emptyData = function (Options $options) { | ||
177 | if ($options['multiple'] || $options['expanded']) { | ||
178 | return array(); | ||
179 | } | ||
180 | |||
181 | return ''; | ||
182 | }; | ||
183 | |||
184 | $emptyValue = function (Options $options) { | ||
185 | return $options['required'] ? null : ''; | ||
186 | }; | ||
187 | |||
188 | $emptyValueNormalizer = function (Options $options, $emptyValue) { | ||
189 | if ($options['multiple']) { | ||
190 | // never use an empty value for this case | ||
191 | return null; | ||
192 | } elseif (false === $emptyValue) { | ||
193 | // an empty value should be added but the user decided otherwise | ||
194 | return null; | ||
195 | } elseif ($options['expanded'] && '' === $emptyValue) { | ||
196 | // never use an empty label for radio buttons | ||
197 | return 'None'; | ||
198 | } | ||
199 | |||
200 | // empty value has been set explicitly | ||
201 | return $emptyValue; | ||
202 | }; | ||
203 | |||
204 | $compound = function (Options $options) { | ||
205 | return $options['expanded']; | ||
206 | }; | ||
207 | |||
208 | $resolver->setDefaults(array( | ||
209 | 'multiple' => false, | ||
210 | 'expanded' => false, | ||
211 | 'choice_list' => $choiceList, | ||
212 | 'choices' => array(), | ||
213 | 'preferred_choices' => array(), | ||
214 | 'empty_data' => $emptyData, | ||
215 | 'empty_value' => $emptyValue, | ||
216 | 'error_bubbling' => false, | ||
217 | 'compound' => $compound, | ||
218 | // The view data is always a string, even if the "data" option | ||
219 | // is manually set to an object. | ||
220 | // See https://github.com/symfony/symfony/pull/5582 | ||
221 | 'data_class' => null, | ||
222 | )); | ||
223 | |||
224 | $resolver->setNormalizers(array( | ||
225 | 'empty_value' => $emptyValueNormalizer, | ||
226 | )); | ||
227 | |||
228 | $resolver->setAllowedTypes(array( | ||
229 | 'choice_list' => array('null', 'Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceListInterface'), | ||
230 | )); | ||
231 | } | ||
232 | |||
233 | /** | ||
234 | * {@inheritdoc} | ||
235 | */ | ||
236 | public function getName() | ||
237 | { | ||
238 | return 'choice'; | ||
239 | } | ||
240 | |||
241 | /** | ||
242 | * Adds the sub fields for an expanded choice field. | ||
243 | * | ||
244 | * @param FormBuilderInterface $builder The form builder. | ||
245 | * @param array $choiceViews The choice view objects. | ||
246 | * @param array $options The build options. | ||
247 | */ | ||
248 | private function addSubForms(FormBuilderInterface $builder, array $choiceViews, array $options) | ||
249 | { | ||
250 | foreach ($choiceViews as $i => $choiceView) { | ||
251 | if (is_array($choiceView)) { | ||
252 | // Flatten groups | ||
253 | $this->addSubForms($builder, $choiceView, $options); | ||
254 | } else { | ||
255 | $choiceOpts = array( | ||
256 | 'value' => $choiceView->value, | ||
257 | 'label' => $choiceView->label, | ||
258 | 'translation_domain' => $options['translation_domain'], | ||
259 | ); | ||
260 | |||
261 | if ($options['multiple']) { | ||
262 | $choiceType = 'checkbox'; | ||
263 | // The user can check 0 or more checkboxes. If required | ||
264 | // is true, he is required to check all of them. | ||
265 | $choiceOpts['required'] = false; | ||
266 | } else { | ||
267 | $choiceType = 'radio'; | ||
268 | } | ||
269 | |||
270 | $builder->add($i, $choiceType, $choiceOpts); | ||
271 | } | ||
272 | } | ||
273 | } | ||
274 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/CollectionType.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/CollectionType.php new file mode 100644 index 00000000..0cb3af1b --- /dev/null +++ b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/CollectionType.php | |||
@@ -0,0 +1,103 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Extension\Core\Type; | ||
13 | |||
14 | use Symfony\Component\Form\AbstractType; | ||
15 | use Symfony\Component\Form\FormBuilderInterface; | ||
16 | use Symfony\Component\Form\FormView; | ||
17 | use Symfony\Component\Form\FormInterface; | ||
18 | use Symfony\Component\Form\Extension\Core\EventListener\ResizeFormListener; | ||
19 | use Symfony\Component\OptionsResolver\Options; | ||
20 | use Symfony\Component\OptionsResolver\OptionsResolverInterface; | ||
21 | |||
22 | class CollectionType extends AbstractType | ||
23 | { | ||
24 | /** | ||
25 | * {@inheritdoc} | ||
26 | */ | ||
27 | public function buildForm(FormBuilderInterface $builder, array $options) | ||
28 | { | ||
29 | if ($options['allow_add'] && $options['prototype']) { | ||
30 | $prototype = $builder->create($options['prototype_name'], $options['type'], array_replace(array( | ||
31 | 'label' => $options['prototype_name'].'label__', | ||
32 | ), $options['options'])); | ||
33 | $builder->setAttribute('prototype', $prototype->getForm()); | ||
34 | } | ||
35 | |||
36 | $resizeListener = new ResizeFormListener( | ||
37 | $options['type'], | ||
38 | $options['options'], | ||
39 | $options['allow_add'], | ||
40 | $options['allow_delete'] | ||
41 | ); | ||
42 | |||
43 | $builder->addEventSubscriber($resizeListener); | ||
44 | } | ||
45 | |||
46 | /** | ||
47 | * {@inheritdoc} | ||
48 | */ | ||
49 | public function buildView(FormView $view, FormInterface $form, array $options) | ||
50 | { | ||
51 | $view->vars = array_replace($view->vars, array( | ||
52 | 'allow_add' => $options['allow_add'], | ||
53 | 'allow_delete' => $options['allow_delete'], | ||
54 | )); | ||
55 | |||
56 | if ($form->getConfig()->hasAttribute('prototype')) { | ||
57 | $view->vars['prototype'] = $form->getConfig()->getAttribute('prototype')->createView($view); | ||
58 | } | ||
59 | } | ||
60 | |||
61 | /** | ||
62 | * {@inheritdoc} | ||
63 | */ | ||
64 | public function finishView(FormView $view, FormInterface $form, array $options) | ||
65 | { | ||
66 | if ($form->getConfig()->hasAttribute('prototype') && $view->vars['prototype']->vars['multipart']) { | ||
67 | $view->vars['multipart'] = true; | ||
68 | } | ||
69 | } | ||
70 | |||
71 | /** | ||
72 | * {@inheritdoc} | ||
73 | */ | ||
74 | public function setDefaultOptions(OptionsResolverInterface $resolver) | ||
75 | { | ||
76 | $optionsNormalizer = function (Options $options, $value) { | ||
77 | $value['block_name'] = 'entry'; | ||
78 | |||
79 | return $value; | ||
80 | }; | ||
81 | |||
82 | $resolver->setDefaults(array( | ||
83 | 'allow_add' => false, | ||
84 | 'allow_delete' => false, | ||
85 | 'prototype' => true, | ||
86 | 'prototype_name' => '__name__', | ||
87 | 'type' => 'text', | ||
88 | 'options' => array(), | ||
89 | )); | ||
90 | |||
91 | $resolver->setNormalizers(array( | ||
92 | 'options' => $optionsNormalizer, | ||
93 | )); | ||
94 | } | ||
95 | |||
96 | /** | ||
97 | * {@inheritdoc} | ||
98 | */ | ||
99 | public function getName() | ||
100 | { | ||
101 | return 'collection'; | ||
102 | } | ||
103 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/CountryType.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/CountryType.php new file mode 100644 index 00000000..3482ba66 --- /dev/null +++ b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/CountryType.php | |||
@@ -0,0 +1,45 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Extension\Core\Type; | ||
13 | |||
14 | use Symfony\Component\Form\AbstractType; | ||
15 | use Symfony\Component\Intl\Intl; | ||
16 | use Symfony\Component\OptionsResolver\OptionsResolverInterface; | ||
17 | |||
18 | class CountryType extends AbstractType | ||
19 | { | ||
20 | /** | ||
21 | * {@inheritdoc} | ||
22 | */ | ||
23 | public function setDefaultOptions(OptionsResolverInterface $resolver) | ||
24 | { | ||
25 | $resolver->setDefaults(array( | ||
26 | 'choices' => Intl::getRegionBundle()->getCountryNames(), | ||
27 | )); | ||
28 | } | ||
29 | |||
30 | /** | ||
31 | * {@inheritdoc} | ||
32 | */ | ||
33 | public function getParent() | ||
34 | { | ||
35 | return 'choice'; | ||
36 | } | ||
37 | |||
38 | /** | ||
39 | * {@inheritdoc} | ||
40 | */ | ||
41 | public function getName() | ||
42 | { | ||
43 | return 'country'; | ||
44 | } | ||
45 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/CurrencyType.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/CurrencyType.php new file mode 100644 index 00000000..3a925e3a --- /dev/null +++ b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/CurrencyType.php | |||
@@ -0,0 +1,45 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Extension\Core\Type; | ||
13 | |||
14 | use Symfony\Component\Form\AbstractType; | ||
15 | use Symfony\Component\Intl\Intl; | ||
16 | use Symfony\Component\OptionsResolver\OptionsResolverInterface; | ||
17 | |||
18 | class CurrencyType extends AbstractType | ||
19 | { | ||
20 | /** | ||
21 | * {@inheritdoc} | ||
22 | */ | ||
23 | public function setDefaultOptions(OptionsResolverInterface $resolver) | ||
24 | { | ||
25 | $resolver->setDefaults(array( | ||
26 | 'choices' => Intl::getCurrencyBundle()->getCurrencyNames(), | ||
27 | )); | ||
28 | } | ||
29 | |||
30 | /** | ||
31 | * {@inheritdoc} | ||
32 | */ | ||
33 | public function getParent() | ||
34 | { | ||
35 | return 'choice'; | ||
36 | } | ||
37 | |||
38 | /** | ||
39 | * {@inheritdoc} | ||
40 | */ | ||
41 | public function getName() | ||
42 | { | ||
43 | return 'currency'; | ||
44 | } | ||
45 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/DateTimeType.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/DateTimeType.php new file mode 100644 index 00000000..a612b6fc --- /dev/null +++ b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/DateTimeType.php | |||
@@ -0,0 +1,281 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Extension\Core\Type; | ||
13 | |||
14 | use Symfony\Component\Form\AbstractType; | ||
15 | use Symfony\Component\OptionsResolver\Exception\InvalidOptionsException; | ||
16 | use Symfony\Component\Form\FormInterface; | ||
17 | use Symfony\Component\Form\FormBuilderInterface; | ||
18 | use Symfony\Component\Form\FormView; | ||
19 | use Symfony\Component\Form\ReversedTransformer; | ||
20 | use Symfony\Component\Form\Extension\Core\DataTransformer\DataTransformerChain; | ||
21 | use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToArrayTransformer; | ||
22 | use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToStringTransformer; | ||
23 | use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToLocalizedStringTransformer; | ||
24 | use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToTimestampTransformer; | ||
25 | use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToRfc3339Transformer; | ||
26 | use Symfony\Component\Form\Extension\Core\DataTransformer\ArrayToPartsTransformer; | ||
27 | use Symfony\Component\OptionsResolver\Options; | ||
28 | use Symfony\Component\OptionsResolver\OptionsResolverInterface; | ||
29 | |||
30 | class DateTimeType extends AbstractType | ||
31 | { | ||
32 | const DEFAULT_DATE_FORMAT = \IntlDateFormatter::MEDIUM; | ||
33 | |||
34 | const DEFAULT_TIME_FORMAT = \IntlDateFormatter::MEDIUM; | ||
35 | |||
36 | /** | ||
37 | * This is not quite the HTML5 format yet, because ICU lacks the | ||
38 | * capability of parsing and generating RFC 3339 dates, which | ||
39 | * are like the below pattern but with a timezone suffix. The | ||
40 | * timezone suffix is | ||
41 | * | ||
42 | * * "Z" for UTC | ||
43 | * * "(-|+)HH:mm" for other timezones (note the colon!) | ||
44 | * | ||
45 | * For more information see: | ||
46 | * | ||
47 | * http://userguide.icu-project.org/formatparse/datetime#TOC-Date-Time-Format-Syntax | ||
48 | * http://www.w3.org/TR/html-markup/input.datetime.html | ||
49 | * http://tools.ietf.org/html/rfc3339 | ||
50 | * | ||
51 | * An ICU ticket was created: | ||
52 | * http://icu-project.org/trac/ticket/9421 | ||
53 | * | ||
54 | * It was supposedly fixed, but is not available in all PHP installations | ||
55 | * yet. To temporarily circumvent this issue, DateTimeToRfc3339Transformer | ||
56 | * is used when the format matches this constant. | ||
57 | */ | ||
58 | const HTML5_FORMAT = "yyyy-MM-dd'T'HH:mm:ssZZZZZ"; | ||
59 | |||
60 | private static $acceptedFormats = array( | ||
61 | \IntlDateFormatter::FULL, | ||
62 | \IntlDateFormatter::LONG, | ||
63 | \IntlDateFormatter::MEDIUM, | ||
64 | \IntlDateFormatter::SHORT, | ||
65 | ); | ||
66 | |||
67 | /** | ||
68 | * {@inheritdoc} | ||
69 | */ | ||
70 | public function buildForm(FormBuilderInterface $builder, array $options) | ||
71 | { | ||
72 | $parts = array('year', 'month', 'day', 'hour'); | ||
73 | $dateParts = array('year', 'month', 'day'); | ||
74 | $timeParts = array('hour'); | ||
75 | |||
76 | if ($options['with_minutes']) { | ||
77 | $parts[] = 'minute'; | ||
78 | $timeParts[] = 'minute'; | ||
79 | } | ||
80 | |||
81 | if ($options['with_seconds']) { | ||
82 | $parts[] = 'second'; | ||
83 | $timeParts[] = 'second'; | ||
84 | } | ||
85 | |||
86 | $dateFormat = is_int($options['date_format']) ? $options['date_format'] : self::DEFAULT_DATE_FORMAT; | ||
87 | $timeFormat = self::DEFAULT_TIME_FORMAT; | ||
88 | $calendar = \IntlDateFormatter::GREGORIAN; | ||
89 | $pattern = is_string($options['format']) ? $options['format'] : null; | ||
90 | |||
91 | if (!in_array($dateFormat, self::$acceptedFormats, true)) { | ||
92 | throw new InvalidOptionsException('The "date_format" option must be one of the IntlDateFormatter constants (FULL, LONG, MEDIUM, SHORT) or a string representing a custom format.'); | ||
93 | } | ||
94 | |||
95 | if ('single_text' === $options['widget']) { | ||
96 | if (self::HTML5_FORMAT === $pattern) { | ||
97 | $builder->addViewTransformer(new DateTimeToRfc3339Transformer( | ||
98 | $options['model_timezone'], | ||
99 | $options['view_timezone'] | ||
100 | )); | ||
101 | } else { | ||
102 | $builder->addViewTransformer(new DateTimeToLocalizedStringTransformer( | ||
103 | $options['model_timezone'], | ||
104 | $options['view_timezone'], | ||
105 | $dateFormat, | ||
106 | $timeFormat, | ||
107 | $calendar, | ||
108 | $pattern | ||
109 | )); | ||
110 | } | ||
111 | } else { | ||
112 | // Only pass a subset of the options to children | ||
113 | $dateOptions = array_intersect_key($options, array_flip(array( | ||
114 | 'years', | ||
115 | 'months', | ||
116 | 'days', | ||
117 | 'empty_value', | ||
118 | 'required', | ||
119 | 'translation_domain', | ||
120 | ))); | ||
121 | |||
122 | $timeOptions = array_intersect_key($options, array_flip(array( | ||
123 | 'hours', | ||
124 | 'minutes', | ||
125 | 'seconds', | ||
126 | 'with_minutes', | ||
127 | 'with_seconds', | ||
128 | 'empty_value', | ||
129 | 'required', | ||
130 | 'translation_domain', | ||
131 | ))); | ||
132 | |||
133 | if (null !== $options['date_widget']) { | ||
134 | $dateOptions['widget'] = $options['date_widget']; | ||
135 | } | ||
136 | |||
137 | if (null !== $options['time_widget']) { | ||
138 | $timeOptions['widget'] = $options['time_widget']; | ||
139 | } | ||
140 | |||
141 | if (null !== $options['date_format']) { | ||
142 | $dateOptions['format'] = $options['date_format']; | ||
143 | } | ||
144 | |||
145 | $dateOptions['input'] = $timeOptions['input'] = 'array'; | ||
146 | $dateOptions['error_bubbling'] = $timeOptions['error_bubbling'] = true; | ||
147 | |||
148 | $builder | ||
149 | ->addViewTransformer(new DataTransformerChain(array( | ||
150 | new DateTimeToArrayTransformer($options['model_timezone'], $options['view_timezone'], $parts), | ||
151 | new ArrayToPartsTransformer(array( | ||
152 | 'date' => $dateParts, | ||
153 | 'time' => $timeParts, | ||
154 | )), | ||
155 | ))) | ||
156 | ->add('date', 'date', $dateOptions) | ||
157 | ->add('time', 'time', $timeOptions) | ||
158 | ; | ||
159 | } | ||
160 | |||
161 | if ('string' === $options['input']) { | ||
162 | $builder->addModelTransformer(new ReversedTransformer( | ||
163 | new DateTimeToStringTransformer($options['model_timezone'], $options['model_timezone']) | ||
164 | )); | ||
165 | } elseif ('timestamp' === $options['input']) { | ||
166 | $builder->addModelTransformer(new ReversedTransformer( | ||
167 | new DateTimeToTimestampTransformer($options['model_timezone'], $options['model_timezone']) | ||
168 | )); | ||
169 | } elseif ('array' === $options['input']) { | ||
170 | $builder->addModelTransformer(new ReversedTransformer( | ||
171 | new DateTimeToArrayTransformer($options['model_timezone'], $options['model_timezone'], $parts) | ||
172 | )); | ||
173 | } | ||
174 | } | ||
175 | |||
176 | /** | ||
177 | * {@inheritdoc} | ||
178 | */ | ||
179 | public function buildView(FormView $view, FormInterface $form, array $options) | ||
180 | { | ||
181 | $view->vars['widget'] = $options['widget']; | ||
182 | |||
183 | // Change the input to a HTML5 date input if | ||
184 | // * the widget is set to "single_text" | ||
185 | // * the format matches the one expected by HTML5 | ||
186 | if ('single_text' === $options['widget'] && self::HTML5_FORMAT === $options['format']) { | ||
187 | $view->vars['type'] = 'datetime'; | ||
188 | } | ||
189 | } | ||
190 | |||
191 | /** | ||
192 | * {@inheritdoc} | ||
193 | */ | ||
194 | public function setDefaultOptions(OptionsResolverInterface $resolver) | ||
195 | { | ||
196 | $compound = function (Options $options) { | ||
197 | return $options['widget'] !== 'single_text'; | ||
198 | }; | ||
199 | |||
200 | // Defaults to the value of "widget" | ||
201 | $dateWidget = function (Options $options) { | ||
202 | return $options['widget']; | ||
203 | }; | ||
204 | |||
205 | // Defaults to the value of "widget" | ||
206 | $timeWidget = function (Options $options) { | ||
207 | return $options['widget']; | ||
208 | }; | ||
209 | |||
210 | $resolver->setDefaults(array( | ||
211 | 'input' => 'datetime', | ||
212 | 'model_timezone' => null, | ||
213 | 'view_timezone' => null, | ||
214 | 'format' => self::HTML5_FORMAT, | ||
215 | 'date_format' => null, | ||
216 | 'widget' => null, | ||
217 | 'date_widget' => $dateWidget, | ||
218 | 'time_widget' => $timeWidget, | ||
219 | 'with_minutes' => true, | ||
220 | 'with_seconds' => false, | ||
221 | // Don't modify \DateTime classes by reference, we treat | ||
222 | // them like immutable value objects | ||
223 | 'by_reference' => false, | ||
224 | 'error_bubbling' => false, | ||
225 | // If initialized with a \DateTime object, FormType initializes | ||
226 | // this option to "\DateTime". Since the internal, normalized | ||
227 | // representation is not \DateTime, but an array, we need to unset | ||
228 | // this option. | ||
229 | 'data_class' => null, | ||
230 | 'compound' => $compound, | ||
231 | )); | ||
232 | |||
233 | // Don't add some defaults in order to preserve the defaults | ||
234 | // set in DateType and TimeType | ||
235 | $resolver->setOptional(array( | ||
236 | 'empty_value', | ||
237 | 'years', | ||
238 | 'months', | ||
239 | 'days', | ||
240 | 'hours', | ||
241 | 'minutes', | ||
242 | 'seconds', | ||
243 | )); | ||
244 | |||
245 | $resolver->setAllowedValues(array( | ||
246 | 'input' => array( | ||
247 | 'datetime', | ||
248 | 'string', | ||
249 | 'timestamp', | ||
250 | 'array', | ||
251 | ), | ||
252 | 'date_widget' => array( | ||
253 | null, // inherit default from DateType | ||
254 | 'single_text', | ||
255 | 'text', | ||
256 | 'choice', | ||
257 | ), | ||
258 | 'time_widget' => array( | ||
259 | null, // inherit default from TimeType | ||
260 | 'single_text', | ||
261 | 'text', | ||
262 | 'choice', | ||
263 | ), | ||
264 | // This option will overwrite "date_widget" and "time_widget" options | ||
265 | 'widget' => array( | ||
266 | null, // default, don't overwrite options | ||
267 | 'single_text', | ||
268 | 'text', | ||
269 | 'choice', | ||
270 | ), | ||
271 | )); | ||
272 | } | ||
273 | |||
274 | /** | ||
275 | * {@inheritdoc} | ||
276 | */ | ||
277 | public function getName() | ||
278 | { | ||
279 | return 'datetime'; | ||
280 | } | ||
281 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/DateType.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/DateType.php new file mode 100644 index 00000000..93d3502e --- /dev/null +++ b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/DateType.php | |||
@@ -0,0 +1,309 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Extension\Core\Type; | ||
13 | |||
14 | use Symfony\Component\Form\AbstractType; | ||
15 | use Symfony\Component\Form\FormInterface; | ||
16 | use Symfony\Component\Form\FormBuilderInterface; | ||
17 | use Symfony\Component\Form\FormView; | ||
18 | use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToLocalizedStringTransformer; | ||
19 | use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToArrayTransformer; | ||
20 | use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToStringTransformer; | ||
21 | use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToTimestampTransformer; | ||
22 | use Symfony\Component\Form\ReversedTransformer; | ||
23 | use Symfony\Component\OptionsResolver\Options; | ||
24 | use Symfony\Component\OptionsResolver\OptionsResolverInterface; | ||
25 | use Symfony\Component\OptionsResolver\Exception\InvalidOptionsException; | ||
26 | |||
27 | class DateType extends AbstractType | ||
28 | { | ||
29 | const DEFAULT_FORMAT = \IntlDateFormatter::MEDIUM; | ||
30 | |||
31 | const HTML5_FORMAT = 'yyyy-MM-dd'; | ||
32 | |||
33 | private static $acceptedFormats = array( | ||
34 | \IntlDateFormatter::FULL, | ||
35 | \IntlDateFormatter::LONG, | ||
36 | \IntlDateFormatter::MEDIUM, | ||
37 | \IntlDateFormatter::SHORT, | ||
38 | ); | ||
39 | |||
40 | /** | ||
41 | * {@inheritdoc} | ||
42 | */ | ||
43 | public function buildForm(FormBuilderInterface $builder, array $options) | ||
44 | { | ||
45 | $dateFormat = is_int($options['format']) ? $options['format'] : self::DEFAULT_FORMAT; | ||
46 | $timeFormat = \IntlDateFormatter::NONE; | ||
47 | $calendar = \IntlDateFormatter::GREGORIAN; | ||
48 | $pattern = is_string($options['format']) ? $options['format'] : null; | ||
49 | |||
50 | if (!in_array($dateFormat, self::$acceptedFormats, true)) { | ||
51 | throw new InvalidOptionsException('The "format" option must be one of the IntlDateFormatter constants (FULL, LONG, MEDIUM, SHORT) or a string representing a custom format.'); | ||
52 | } | ||
53 | |||
54 | if (null !== $pattern && (false === strpos($pattern, 'y') || false === strpos($pattern, 'M') || false === strpos($pattern, 'd'))) { | ||
55 | throw new InvalidOptionsException(sprintf('The "format" option should contain the letters "y", "M" and "d". Its current value is "%s".', $pattern)); | ||
56 | } | ||
57 | |||
58 | if ('single_text' === $options['widget']) { | ||
59 | $builder->addViewTransformer(new DateTimeToLocalizedStringTransformer( | ||
60 | $options['model_timezone'], | ||
61 | $options['view_timezone'], | ||
62 | $dateFormat, | ||
63 | $timeFormat, | ||
64 | $calendar, | ||
65 | $pattern | ||
66 | )); | ||
67 | } else { | ||
68 | $yearOptions = $monthOptions = $dayOptions = array( | ||
69 | 'error_bubbling' => true, | ||
70 | ); | ||
71 | |||
72 | $formatter = new \IntlDateFormatter( | ||
73 | \Locale::getDefault(), | ||
74 | $dateFormat, | ||
75 | $timeFormat, | ||
76 | 'UTC', | ||
77 | $calendar, | ||
78 | $pattern | ||
79 | ); | ||
80 | $formatter->setLenient(false); | ||
81 | |||
82 | if ('choice' === $options['widget']) { | ||
83 | // Only pass a subset of the options to children | ||
84 | $yearOptions['choices'] = $this->formatTimestamps($formatter, '/y+/', $this->listYears($options['years'])); | ||
85 | $yearOptions['empty_value'] = $options['empty_value']['year']; | ||
86 | $monthOptions['choices'] = $this->formatTimestamps($formatter, '/[M|L]+/', $this->listMonths($options['months'])); | ||
87 | $monthOptions['empty_value'] = $options['empty_value']['month']; | ||
88 | $dayOptions['choices'] = $this->formatTimestamps($formatter, '/d+/', $this->listDays($options['days'])); | ||
89 | $dayOptions['empty_value'] = $options['empty_value']['day']; | ||
90 | } | ||
91 | |||
92 | // Append generic carry-along options | ||
93 | foreach (array('required', 'translation_domain') as $passOpt) { | ||
94 | $yearOptions[$passOpt] = $monthOptions[$passOpt] = $dayOptions[$passOpt] = $options[$passOpt]; | ||
95 | } | ||
96 | |||
97 | $builder | ||
98 | ->add('year', $options['widget'], $yearOptions) | ||
99 | ->add('month', $options['widget'], $monthOptions) | ||
100 | ->add('day', $options['widget'], $dayOptions) | ||
101 | ->addViewTransformer(new DateTimeToArrayTransformer( | ||
102 | $options['model_timezone'], $options['view_timezone'], array('year', 'month', 'day') | ||
103 | )) | ||
104 | ->setAttribute('formatter', $formatter) | ||
105 | ; | ||
106 | } | ||
107 | |||
108 | if ('string' === $options['input']) { | ||
109 | $builder->addModelTransformer(new ReversedTransformer( | ||
110 | new DateTimeToStringTransformer($options['model_timezone'], $options['model_timezone'], 'Y-m-d') | ||
111 | )); | ||
112 | } elseif ('timestamp' === $options['input']) { | ||
113 | $builder->addModelTransformer(new ReversedTransformer( | ||
114 | new DateTimeToTimestampTransformer($options['model_timezone'], $options['model_timezone']) | ||
115 | )); | ||
116 | } elseif ('array' === $options['input']) { | ||
117 | $builder->addModelTransformer(new ReversedTransformer( | ||
118 | new DateTimeToArrayTransformer($options['model_timezone'], $options['model_timezone'], array('year', 'month', 'day')) | ||
119 | )); | ||
120 | } | ||
121 | } | ||
122 | |||
123 | /** | ||
124 | * {@inheritdoc} | ||
125 | */ | ||
126 | public function finishView(FormView $view, FormInterface $form, array $options) | ||
127 | { | ||
128 | $view->vars['widget'] = $options['widget']; | ||
129 | |||
130 | // Change the input to a HTML5 date input if | ||
131 | // * the widget is set to "single_text" | ||
132 | // * the format matches the one expected by HTML5 | ||
133 | if ('single_text' === $options['widget'] && self::HTML5_FORMAT === $options['format']) { | ||
134 | $view->vars['type'] = 'date'; | ||
135 | } | ||
136 | |||
137 | if ($form->getConfig()->hasAttribute('formatter')) { | ||
138 | $pattern = $form->getConfig()->getAttribute('formatter')->getPattern(); | ||
139 | |||
140 | // remove special characters unless the format was explicitly specified | ||
141 | if (!is_string($options['format'])) { | ||
142 | $pattern = preg_replace('/[^yMd]+/', '', $pattern); | ||
143 | } | ||
144 | |||
145 | // set right order with respect to locale (e.g.: de_DE=dd.MM.yy; en_US=M/d/yy) | ||
146 | // lookup various formats at http://userguide.icu-project.org/formatparse/datetime | ||
147 | if (preg_match('/^([yMd]+)[^yMd]*([yMd]+)[^yMd]*([yMd]+)$/', $pattern)) { | ||
148 | $pattern = preg_replace(array('/y+/', '/M+/', '/d+/'), array('{{ year }}', '{{ month }}', '{{ day }}'), $pattern); | ||
149 | } else { | ||
150 | // default fallback | ||
151 | $pattern = '{{ year }}{{ month }}{{ day }}'; | ||
152 | } | ||
153 | |||
154 | $view->vars['date_pattern'] = $pattern; | ||
155 | } | ||
156 | } | ||
157 | |||
158 | /** | ||
159 | * {@inheritdoc} | ||
160 | */ | ||
161 | public function setDefaultOptions(OptionsResolverInterface $resolver) | ||
162 | { | ||
163 | $compound = function (Options $options) { | ||
164 | return $options['widget'] !== 'single_text'; | ||
165 | }; | ||
166 | |||
167 | $emptyValue = $emptyValueDefault = function (Options $options) { | ||
168 | return $options['required'] ? null : ''; | ||
169 | }; | ||
170 | |||
171 | $emptyValueNormalizer = function (Options $options, $emptyValue) use ($emptyValueDefault) { | ||
172 | if (is_array($emptyValue)) { | ||
173 | $default = $emptyValueDefault($options); | ||
174 | |||
175 | return array_merge( | ||
176 | array('year' => $default, 'month' => $default, 'day' => $default), | ||
177 | $emptyValue | ||
178 | ); | ||
179 | } | ||
180 | |||
181 | return array( | ||
182 | 'year' => $emptyValue, | ||
183 | 'month' => $emptyValue, | ||
184 | 'day' => $emptyValue | ||
185 | ); | ||
186 | }; | ||
187 | |||
188 | $format = function (Options $options) { | ||
189 | return $options['widget'] === 'single_text' ? DateType::HTML5_FORMAT : DateType::DEFAULT_FORMAT; | ||
190 | }; | ||
191 | |||
192 | $resolver->setDefaults(array( | ||
193 | 'years' => range(date('Y') - 5, date('Y') + 5), | ||
194 | 'months' => range(1, 12), | ||
195 | 'days' => range(1, 31), | ||
196 | 'widget' => 'choice', | ||
197 | 'input' => 'datetime', | ||
198 | 'format' => $format, | ||
199 | 'model_timezone' => null, | ||
200 | 'view_timezone' => null, | ||
201 | 'empty_value' => $emptyValue, | ||
202 | // Don't modify \DateTime classes by reference, we treat | ||
203 | // them like immutable value objects | ||
204 | 'by_reference' => false, | ||
205 | 'error_bubbling' => false, | ||
206 | // If initialized with a \DateTime object, FormType initializes | ||
207 | // this option to "\DateTime". Since the internal, normalized | ||
208 | // representation is not \DateTime, but an array, we need to unset | ||
209 | // this option. | ||
210 | 'data_class' => null, | ||
211 | 'compound' => $compound, | ||
212 | )); | ||
213 | |||
214 | $resolver->setNormalizers(array( | ||
215 | 'empty_value' => $emptyValueNormalizer, | ||
216 | )); | ||
217 | |||
218 | $resolver->setAllowedValues(array( | ||
219 | 'input' => array( | ||
220 | 'datetime', | ||
221 | 'string', | ||
222 | 'timestamp', | ||
223 | 'array', | ||
224 | ), | ||
225 | 'widget' => array( | ||
226 | 'single_text', | ||
227 | 'text', | ||
228 | 'choice', | ||
229 | ), | ||
230 | )); | ||
231 | |||
232 | $resolver->setAllowedTypes(array( | ||
233 | 'format' => array('int', 'string'), | ||
234 | )); | ||
235 | } | ||
236 | |||
237 | /** | ||
238 | * {@inheritdoc} | ||
239 | */ | ||
240 | public function getName() | ||
241 | { | ||
242 | return 'date'; | ||
243 | } | ||
244 | |||
245 | private function formatTimestamps(\IntlDateFormatter $formatter, $regex, array $timestamps) | ||
246 | { | ||
247 | $pattern = $formatter->getPattern(); | ||
248 | $timezone = $formatter->getTimezoneId(); | ||
249 | |||
250 | if (version_compare(\PHP_VERSION, '5.5.0-dev', '>=')) { | ||
251 | $formatter->setTimeZone(\DateTimeZone::UTC); | ||
252 | } else { | ||
253 | $formatter->setTimeZoneId(\DateTimeZone::UTC); | ||
254 | } | ||
255 | |||
256 | if (preg_match($regex, $pattern, $matches)) { | ||
257 | $formatter->setPattern($matches[0]); | ||
258 | |||
259 | foreach ($timestamps as $key => $timestamp) { | ||
260 | $timestamps[$key] = $formatter->format($timestamp); | ||
261 | } | ||
262 | |||
263 | // I'd like to clone the formatter above, but then we get a | ||
264 | // segmentation fault, so let's restore the old state instead | ||
265 | $formatter->setPattern($pattern); | ||
266 | } | ||
267 | |||
268 | if (version_compare(\PHP_VERSION, '5.5.0-dev', '>=')) { | ||
269 | $formatter->setTimeZone($timezone); | ||
270 | } else { | ||
271 | $formatter->setTimeZoneId($timezone); | ||
272 | } | ||
273 | |||
274 | return $timestamps; | ||
275 | } | ||
276 | |||
277 | private function listYears(array $years) | ||
278 | { | ||
279 | $result = array(); | ||
280 | |||
281 | foreach ($years as $year) { | ||
282 | $result[$year] = gmmktime(0, 0, 0, 6, 15, $year); | ||
283 | } | ||
284 | |||
285 | return $result; | ||
286 | } | ||
287 | |||
288 | private function listMonths(array $months) | ||
289 | { | ||
290 | $result = array(); | ||
291 | |||
292 | foreach ($months as $month) { | ||
293 | $result[$month] = gmmktime(0, 0, 0, $month, 15); | ||
294 | } | ||
295 | |||
296 | return $result; | ||
297 | } | ||
298 | |||
299 | private function listDays(array $days) | ||
300 | { | ||
301 | $result = array(); | ||
302 | |||
303 | foreach ($days as $day) { | ||
304 | $result[$day] = gmmktime(0, 0, 0, 5, $day); | ||
305 | } | ||
306 | |||
307 | return $result; | ||
308 | } | ||
309 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/EmailType.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/EmailType.php new file mode 100644 index 00000000..26652ef6 --- /dev/null +++ b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/EmailType.php | |||
@@ -0,0 +1,33 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Extension\Core\Type; | ||
13 | |||
14 | use Symfony\Component\Form\AbstractType; | ||
15 | |||
16 | class EmailType extends AbstractType | ||
17 | { | ||
18 | /** | ||
19 | * {@inheritdoc} | ||
20 | */ | ||
21 | public function getParent() | ||
22 | { | ||
23 | return 'text'; | ||
24 | } | ||
25 | |||
26 | /** | ||
27 | * {@inheritdoc} | ||
28 | */ | ||
29 | public function getName() | ||
30 | { | ||
31 | return 'email'; | ||
32 | } | ||
33 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/FileType.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/FileType.php new file mode 100644 index 00000000..2c09da6f --- /dev/null +++ b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/FileType.php | |||
@@ -0,0 +1,61 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Extension\Core\Type; | ||
13 | |||
14 | use Symfony\Component\Form\AbstractType; | ||
15 | use Symfony\Component\Form\FormInterface; | ||
16 | use Symfony\Component\Form\FormView; | ||
17 | use Symfony\Component\OptionsResolver\OptionsResolverInterface; | ||
18 | |||
19 | class FileType extends AbstractType | ||
20 | { | ||
21 | /** | ||
22 | * {@inheritdoc} | ||
23 | */ | ||
24 | public function buildView(FormView $view, FormInterface $form, array $options) | ||
25 | { | ||
26 | $view->vars = array_replace($view->vars, array( | ||
27 | 'type' => 'file', | ||
28 | 'value' => '', | ||
29 | )); | ||
30 | } | ||
31 | |||
32 | /** | ||
33 | * {@inheritdoc} | ||
34 | */ | ||
35 | public function finishView(FormView $view, FormInterface $form, array $options) | ||
36 | { | ||
37 | $view | ||
38 | ->vars['multipart'] = true | ||
39 | ; | ||
40 | } | ||
41 | |||
42 | /** | ||
43 | * {@inheritdoc} | ||
44 | */ | ||
45 | public function setDefaultOptions(OptionsResolverInterface $resolver) | ||
46 | { | ||
47 | $resolver->setDefaults(array( | ||
48 | 'compound' => false, | ||
49 | 'data_class' => 'Symfony\Component\HttpFoundation\File\File', | ||
50 | 'empty_data' => null, | ||
51 | )); | ||
52 | } | ||
53 | |||
54 | /** | ||
55 | * {@inheritdoc} | ||
56 | */ | ||
57 | public function getName() | ||
58 | { | ||
59 | return 'file'; | ||
60 | } | ||
61 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/FormType.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/FormType.php new file mode 100644 index 00000000..0c39d3eb --- /dev/null +++ b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/FormType.php | |||
@@ -0,0 +1,214 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Extension\Core\Type; | ||
13 | |||
14 | use Symfony\Component\Form\FormBuilderInterface; | ||
15 | use Symfony\Component\Form\FormInterface; | ||
16 | use Symfony\Component\Form\FormView; | ||
17 | use Symfony\Component\Form\Extension\Core\EventListener\TrimListener; | ||
18 | use Symfony\Component\Form\Extension\Core\DataMapper\PropertyPathMapper; | ||
19 | use Symfony\Component\Form\Exception\LogicException; | ||
20 | use Symfony\Component\OptionsResolver\Options; | ||
21 | use Symfony\Component\OptionsResolver\OptionsResolverInterface; | ||
22 | use Symfony\Component\PropertyAccess\PropertyAccess; | ||
23 | use Symfony\Component\PropertyAccess\PropertyAccessorInterface; | ||
24 | |||
25 | class FormType extends BaseType | ||
26 | { | ||
27 | /** | ||
28 | * @var PropertyAccessorInterface | ||
29 | */ | ||
30 | private $propertyAccessor; | ||
31 | |||
32 | public function __construct(PropertyAccessorInterface $propertyAccessor = null) | ||
33 | { | ||
34 | $this->propertyAccessor = $propertyAccessor ?: PropertyAccess::getPropertyAccessor(); | ||
35 | } | ||
36 | |||
37 | /** | ||
38 | * {@inheritdoc} | ||
39 | */ | ||
40 | public function buildForm(FormBuilderInterface $builder, array $options) | ||
41 | { | ||
42 | parent::buildForm($builder, $options); | ||
43 | |||
44 | $builder | ||
45 | ->setRequired($options['required']) | ||
46 | ->setErrorBubbling($options['error_bubbling']) | ||
47 | ->setEmptyData($options['empty_data']) | ||
48 | ->setPropertyPath($options['property_path']) | ||
49 | ->setMapped($options['mapped']) | ||
50 | ->setByReference($options['by_reference']) | ||
51 | ->setInheritData($options['inherit_data']) | ||
52 | ->setCompound($options['compound']) | ||
53 | ->setData(isset($options['data']) ? $options['data'] : null) | ||
54 | ->setDataLocked(isset($options['data'])) | ||
55 | ->setDataMapper($options['compound'] ? new PropertyPathMapper($this->propertyAccessor) : null) | ||
56 | ->setMethod($options['method']) | ||
57 | ->setAction($options['action']) | ||
58 | ->setAutoInitialize($options['auto_initialize']) | ||
59 | ; | ||
60 | |||
61 | if ($options['trim']) { | ||
62 | $builder->addEventSubscriber(new TrimListener()); | ||
63 | } | ||
64 | } | ||
65 | |||
66 | /** | ||
67 | * {@inheritdoc} | ||
68 | */ | ||
69 | public function buildView(FormView $view, FormInterface $form, array $options) | ||
70 | { | ||
71 | parent::buildView($view, $form, $options); | ||
72 | |||
73 | $name = $form->getName(); | ||
74 | $readOnly = $options['read_only']; | ||
75 | |||
76 | if ($view->parent) { | ||
77 | if ('' === $name) { | ||
78 | throw new LogicException('Form node with empty name can be used only as root form node.'); | ||
79 | } | ||
80 | |||
81 | // Complex fields are read-only if they themselves or their parents are. | ||
82 | if (!$readOnly) { | ||
83 | $readOnly = $view->parent->vars['read_only']; | ||
84 | } | ||
85 | } | ||
86 | |||
87 | $view->vars = array_replace($view->vars, array( | ||
88 | 'read_only' => $readOnly, | ||
89 | 'errors' => $form->getErrors(), | ||
90 | 'valid' => $form->isSubmitted() ? $form->isValid() : true, | ||
91 | 'value' => $form->getViewData(), | ||
92 | 'data' => $form->getNormData(), | ||
93 | 'required' => $form->isRequired(), | ||
94 | 'max_length' => $options['max_length'], | ||
95 | 'pattern' => $options['pattern'], | ||
96 | 'size' => null, | ||
97 | 'label_attr' => $options['label_attr'], | ||
98 | 'compound' => $form->getConfig()->getCompound(), | ||
99 | 'method' => $form->getConfig()->getMethod(), | ||
100 | 'action' => $form->getConfig()->getAction(), | ||
101 | )); | ||
102 | } | ||
103 | |||
104 | /** | ||
105 | * {@inheritdoc} | ||
106 | */ | ||
107 | public function finishView(FormView $view, FormInterface $form, array $options) | ||
108 | { | ||
109 | $multipart = false; | ||
110 | |||
111 | foreach ($view->children as $child) { | ||
112 | if ($child->vars['multipart']) { | ||
113 | $multipart = true; | ||
114 | break; | ||
115 | } | ||
116 | } | ||
117 | |||
118 | $view->vars['multipart'] = $multipart; | ||
119 | } | ||
120 | |||
121 | /** | ||
122 | * {@inheritdoc} | ||
123 | */ | ||
124 | public function setDefaultOptions(OptionsResolverInterface $resolver) | ||
125 | { | ||
126 | parent::setDefaultOptions($resolver); | ||
127 | |||
128 | // Derive "data_class" option from passed "data" object | ||
129 | $dataClass = function (Options $options) { | ||
130 | return isset($options['data']) && is_object($options['data']) ? get_class($options['data']) : null; | ||
131 | }; | ||
132 | |||
133 | // Derive "empty_data" closure from "data_class" option | ||
134 | $emptyData = function (Options $options) { | ||
135 | $class = $options['data_class']; | ||
136 | |||
137 | if (null !== $class) { | ||
138 | return function (FormInterface $form) use ($class) { | ||
139 | return $form->isEmpty() && !$form->isRequired() ? null : new $class(); | ||
140 | }; | ||
141 | } | ||
142 | |||
143 | return function (FormInterface $form) { | ||
144 | return $form->getConfig()->getCompound() ? array() : ''; | ||
145 | }; | ||
146 | }; | ||
147 | |||
148 | // For any form that is not represented by a single HTML control, | ||
149 | // errors should bubble up by default | ||
150 | $errorBubbling = function (Options $options) { | ||
151 | return $options['compound']; | ||
152 | }; | ||
153 | |||
154 | // BC with old "virtual" option | ||
155 | $inheritData = function (Options $options) { | ||
156 | if (null !== $options['virtual']) { | ||
157 | // Uncomment this as soon as the deprecation note should be shown | ||
158 | // trigger_error('The form option "virtual" is deprecated since version 2.3 and will be removed in 3.0. Use "inherit_data" instead.', E_USER_DEPRECATED); | ||
159 | return $options['virtual']; | ||
160 | } | ||
161 | |||
162 | return false; | ||
163 | }; | ||
164 | |||
165 | // If data is given, the form is locked to that data | ||
166 | // (independent of its value) | ||
167 | $resolver->setOptional(array( | ||
168 | 'data', | ||
169 | )); | ||
170 | |||
171 | $resolver->setDefaults(array( | ||
172 | 'data_class' => $dataClass, | ||
173 | 'empty_data' => $emptyData, | ||
174 | 'trim' => true, | ||
175 | 'required' => true, | ||
176 | 'read_only' => false, | ||
177 | 'max_length' => null, | ||
178 | 'pattern' => null, | ||
179 | 'property_path' => null, | ||
180 | 'mapped' => true, | ||
181 | 'by_reference' => true, | ||
182 | 'error_bubbling' => $errorBubbling, | ||
183 | 'label_attr' => array(), | ||
184 | 'virtual' => null, | ||
185 | 'inherit_data' => $inheritData, | ||
186 | 'compound' => true, | ||
187 | 'method' => 'POST', | ||
188 | // According to RFC 2396 (http://www.ietf.org/rfc/rfc2396.txt) | ||
189 | // section 4.2., empty URIs are considered same-document references | ||
190 | 'action' => '', | ||
191 | 'auto_initialize' => true, | ||
192 | )); | ||
193 | |||
194 | $resolver->setAllowedTypes(array( | ||
195 | 'label_attr' => 'array', | ||
196 | )); | ||
197 | } | ||
198 | |||
199 | /** | ||
200 | * {@inheritdoc} | ||
201 | */ | ||
202 | public function getParent() | ||
203 | { | ||
204 | return null; | ||
205 | } | ||
206 | |||
207 | /** | ||
208 | * {@inheritdoc} | ||
209 | */ | ||
210 | public function getName() | ||
211 | { | ||
212 | return 'form'; | ||
213 | } | ||
214 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/HiddenType.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/HiddenType.php new file mode 100644 index 00000000..bd4fa898 --- /dev/null +++ b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/HiddenType.php | |||
@@ -0,0 +1,40 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Extension\Core\Type; | ||
13 | |||
14 | use Symfony\Component\Form\AbstractType; | ||
15 | use Symfony\Component\OptionsResolver\OptionsResolverInterface; | ||
16 | |||
17 | class HiddenType extends AbstractType | ||
18 | { | ||
19 | /** | ||
20 | * {@inheritdoc} | ||
21 | */ | ||
22 | public function setDefaultOptions(OptionsResolverInterface $resolver) | ||
23 | { | ||
24 | $resolver->setDefaults(array( | ||
25 | // hidden fields cannot have a required attribute | ||
26 | 'required' => false, | ||
27 | // Pass errors to the parent | ||
28 | 'error_bubbling' => true, | ||
29 | 'compound' => false, | ||
30 | )); | ||
31 | } | ||
32 | |||
33 | /** | ||
34 | * {@inheritdoc} | ||
35 | */ | ||
36 | public function getName() | ||
37 | { | ||
38 | return 'hidden'; | ||
39 | } | ||
40 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/IntegerType.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/IntegerType.php new file mode 100644 index 00000000..b224cac5 --- /dev/null +++ b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/IntegerType.php | |||
@@ -0,0 +1,68 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Extension\Core\Type; | ||
13 | |||
14 | use Symfony\Component\Form\AbstractType; | ||
15 | use Symfony\Component\Form\FormBuilderInterface; | ||
16 | use Symfony\Component\Form\Extension\Core\DataTransformer\IntegerToLocalizedStringTransformer; | ||
17 | use Symfony\Component\OptionsResolver\OptionsResolverInterface; | ||
18 | |||
19 | class IntegerType extends AbstractType | ||
20 | { | ||
21 | /** | ||
22 | * {@inheritdoc} | ||
23 | */ | ||
24 | public function buildForm(FormBuilderInterface $builder, array $options) | ||
25 | { | ||
26 | $builder->addViewTransformer( | ||
27 | new IntegerToLocalizedStringTransformer( | ||
28 | $options['precision'], | ||
29 | $options['grouping'], | ||
30 | $options['rounding_mode'] | ||
31 | )); | ||
32 | } | ||
33 | |||
34 | /** | ||
35 | * {@inheritdoc} | ||
36 | */ | ||
37 | public function setDefaultOptions(OptionsResolverInterface $resolver) | ||
38 | { | ||
39 | $resolver->setDefaults(array( | ||
40 | // default precision is locale specific (usually around 3) | ||
41 | 'precision' => null, | ||
42 | 'grouping' => false, | ||
43 | // Integer cast rounds towards 0, so do the same when displaying fractions | ||
44 | 'rounding_mode' => \NumberFormatter::ROUND_DOWN, | ||
45 | 'compound' => false, | ||
46 | )); | ||
47 | |||
48 | $resolver->setAllowedValues(array( | ||
49 | 'rounding_mode' => array( | ||
50 | \NumberFormatter::ROUND_FLOOR, | ||
51 | \NumberFormatter::ROUND_DOWN, | ||
52 | \NumberFormatter::ROUND_HALFDOWN, | ||
53 | \NumberFormatter::ROUND_HALFEVEN, | ||
54 | \NumberFormatter::ROUND_HALFUP, | ||
55 | \NumberFormatter::ROUND_UP, | ||
56 | \NumberFormatter::ROUND_CEILING, | ||
57 | ), | ||
58 | )); | ||
59 | } | ||
60 | |||
61 | /** | ||
62 | * {@inheritdoc} | ||
63 | */ | ||
64 | public function getName() | ||
65 | { | ||
66 | return 'integer'; | ||
67 | } | ||
68 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/LanguageType.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/LanguageType.php new file mode 100644 index 00000000..37b2bf33 --- /dev/null +++ b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/LanguageType.php | |||
@@ -0,0 +1,45 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Extension\Core\Type; | ||
13 | |||
14 | use Symfony\Component\Form\AbstractType; | ||
15 | use Symfony\Component\Intl\Intl; | ||
16 | use Symfony\Component\OptionsResolver\OptionsResolverInterface; | ||
17 | |||
18 | class LanguageType extends AbstractType | ||
19 | { | ||
20 | /** | ||
21 | * {@inheritdoc} | ||
22 | */ | ||
23 | public function setDefaultOptions(OptionsResolverInterface $resolver) | ||
24 | { | ||
25 | $resolver->setDefaults(array( | ||
26 | 'choices' => Intl::getLanguageBundle()->getLanguageNames(), | ||
27 | )); | ||
28 | } | ||
29 | |||
30 | /** | ||
31 | * {@inheritdoc} | ||
32 | */ | ||
33 | public function getParent() | ||
34 | { | ||
35 | return 'choice'; | ||
36 | } | ||
37 | |||
38 | /** | ||
39 | * {@inheritdoc} | ||
40 | */ | ||
41 | public function getName() | ||
42 | { | ||
43 | return 'language'; | ||
44 | } | ||
45 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/LocaleType.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/LocaleType.php new file mode 100644 index 00000000..c68c561a --- /dev/null +++ b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/LocaleType.php | |||
@@ -0,0 +1,46 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Extension\Core\Type; | ||
13 | |||
14 | use Symfony\Component\Form\AbstractType; | ||
15 | use Symfony\Component\Intl\Intl; | ||
16 | use Symfony\Component\Locale\Locale; | ||
17 | use Symfony\Component\OptionsResolver\OptionsResolverInterface; | ||
18 | |||
19 | class LocaleType extends AbstractType | ||
20 | { | ||
21 | /** | ||
22 | * {@inheritdoc} | ||
23 | */ | ||
24 | public function setDefaultOptions(OptionsResolverInterface $resolver) | ||
25 | { | ||
26 | $resolver->setDefaults(array( | ||
27 | 'choices' => Intl::getLocaleBundle()->getLocaleNames(), | ||
28 | )); | ||
29 | } | ||
30 | |||
31 | /** | ||
32 | * {@inheritdoc} | ||
33 | */ | ||
34 | public function getParent() | ||
35 | { | ||
36 | return 'choice'; | ||
37 | } | ||
38 | |||
39 | /** | ||
40 | * {@inheritdoc} | ||
41 | */ | ||
42 | public function getName() | ||
43 | { | ||
44 | return 'locale'; | ||
45 | } | ||
46 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/MoneyType.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/MoneyType.php new file mode 100644 index 00000000..9e36f9ce --- /dev/null +++ b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/MoneyType.php | |||
@@ -0,0 +1,111 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Extension\Core\Type; | ||
13 | |||
14 | use Symfony\Component\Form\AbstractType; | ||
15 | use Symfony\Component\Form\FormInterface; | ||
16 | use Symfony\Component\Form\FormBuilderInterface; | ||
17 | use Symfony\Component\Form\Extension\Core\DataTransformer\MoneyToLocalizedStringTransformer; | ||
18 | use Symfony\Component\Form\FormView; | ||
19 | use Symfony\Component\OptionsResolver\OptionsResolverInterface; | ||
20 | |||
21 | class MoneyType extends AbstractType | ||
22 | { | ||
23 | protected static $patterns = array(); | ||
24 | |||
25 | /** | ||
26 | * {@inheritdoc} | ||
27 | */ | ||
28 | public function buildForm(FormBuilderInterface $builder, array $options) | ||
29 | { | ||
30 | $builder | ||
31 | ->addViewTransformer(new MoneyToLocalizedStringTransformer( | ||
32 | $options['precision'], | ||
33 | $options['grouping'], | ||
34 | null, | ||
35 | $options['divisor'] | ||
36 | )) | ||
37 | ; | ||
38 | } | ||
39 | |||
40 | /** | ||
41 | * {@inheritdoc} | ||
42 | */ | ||
43 | public function buildView(FormView $view, FormInterface $form, array $options) | ||
44 | { | ||
45 | $view->vars['money_pattern'] = self::getPattern($options['currency']); | ||
46 | } | ||
47 | |||
48 | /** | ||
49 | * {@inheritdoc} | ||
50 | */ | ||
51 | public function setDefaultOptions(OptionsResolverInterface $resolver) | ||
52 | { | ||
53 | $resolver->setDefaults(array( | ||
54 | 'precision' => 2, | ||
55 | 'grouping' => false, | ||
56 | 'divisor' => 1, | ||
57 | 'currency' => 'EUR', | ||
58 | 'compound' => false, | ||
59 | )); | ||
60 | } | ||
61 | |||
62 | /** | ||
63 | * {@inheritdoc} | ||
64 | */ | ||
65 | public function getName() | ||
66 | { | ||
67 | return 'money'; | ||
68 | } | ||
69 | |||
70 | /** | ||
71 | * Returns the pattern for this locale | ||
72 | * | ||
73 | * The pattern contains the placeholder "{{ widget }}" where the HTML tag should | ||
74 | * be inserted | ||
75 | */ | ||
76 | protected static function getPattern($currency) | ||
77 | { | ||
78 | if (!$currency) { | ||
79 | return '{{ widget }}'; | ||
80 | } | ||
81 | |||
82 | $locale = \Locale::getDefault(); | ||
83 | |||
84 | if (!isset(self::$patterns[$locale])) { | ||
85 | self::$patterns[$locale] = array(); | ||
86 | } | ||
87 | |||
88 | if (!isset(self::$patterns[$locale][$currency])) { | ||
89 | $format = new \NumberFormatter($locale, \NumberFormatter::CURRENCY); | ||
90 | $pattern = $format->formatCurrency('123', $currency); | ||
91 | |||
92 | // the spacings between currency symbol and number are ignored, because | ||
93 | // a single space leads to better readability in combination with input | ||
94 | // fields | ||
95 | |||
96 | // the regex also considers non-break spaces (0xC2 or 0xA0 in UTF-8) | ||
97 | |||
98 | preg_match('/^([^\s\xc2\xa0]*)[\s\xc2\xa0]*123(?:[,.]0+)?[\s\xc2\xa0]*([^\s\xc2\xa0]*)$/u', $pattern, $matches); | ||
99 | |||
100 | if (!empty($matches[1])) { | ||
101 | self::$patterns[$locale][$currency] = $matches[1].' {{ widget }}'; | ||
102 | } elseif (!empty($matches[2])) { | ||
103 | self::$patterns[$locale][$currency] = '{{ widget }} '.$matches[2]; | ||
104 | } else { | ||
105 | self::$patterns[$locale][$currency] = '{{ widget }}'; | ||
106 | } | ||
107 | } | ||
108 | |||
109 | return self::$patterns[$locale][$currency]; | ||
110 | } | ||
111 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/NumberType.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/NumberType.php new file mode 100644 index 00000000..beb3c89a --- /dev/null +++ b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/NumberType.php | |||
@@ -0,0 +1,66 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Extension\Core\Type; | ||
13 | |||
14 | use Symfony\Component\Form\AbstractType; | ||
15 | use Symfony\Component\Form\FormBuilderInterface; | ||
16 | use Symfony\Component\Form\Extension\Core\DataTransformer\NumberToLocalizedStringTransformer; | ||
17 | use Symfony\Component\OptionsResolver\OptionsResolverInterface; | ||
18 | |||
19 | class NumberType extends AbstractType | ||
20 | { | ||
21 | /** | ||
22 | * {@inheritdoc} | ||
23 | */ | ||
24 | public function buildForm(FormBuilderInterface $builder, array $options) | ||
25 | { | ||
26 | $builder->addViewTransformer(new NumberToLocalizedStringTransformer( | ||
27 | $options['precision'], | ||
28 | $options['grouping'], | ||
29 | $options['rounding_mode'] | ||
30 | )); | ||
31 | } | ||
32 | |||
33 | /** | ||
34 | * {@inheritdoc} | ||
35 | */ | ||
36 | public function setDefaultOptions(OptionsResolverInterface $resolver) | ||
37 | { | ||
38 | $resolver->setDefaults(array( | ||
39 | // default precision is locale specific (usually around 3) | ||
40 | 'precision' => null, | ||
41 | 'grouping' => false, | ||
42 | 'rounding_mode' => \NumberFormatter::ROUND_HALFUP, | ||
43 | 'compound' => false, | ||
44 | )); | ||
45 | |||
46 | $resolver->setAllowedValues(array( | ||
47 | 'rounding_mode' => array( | ||
48 | \NumberFormatter::ROUND_FLOOR, | ||
49 | \NumberFormatter::ROUND_DOWN, | ||
50 | \NumberFormatter::ROUND_HALFDOWN, | ||
51 | \NumberFormatter::ROUND_HALFEVEN, | ||
52 | \NumberFormatter::ROUND_HALFUP, | ||
53 | \NumberFormatter::ROUND_UP, | ||
54 | \NumberFormatter::ROUND_CEILING, | ||
55 | ), | ||
56 | )); | ||
57 | } | ||
58 | |||
59 | /** | ||
60 | * {@inheritdoc} | ||
61 | */ | ||
62 | public function getName() | ||
63 | { | ||
64 | return 'number'; | ||
65 | } | ||
66 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/PasswordType.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/PasswordType.php new file mode 100644 index 00000000..5a5b1635 --- /dev/null +++ b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/PasswordType.php | |||
@@ -0,0 +1,57 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Extension\Core\Type; | ||
13 | |||
14 | use Symfony\Component\Form\AbstractType; | ||
15 | use Symfony\Component\Form\FormInterface; | ||
16 | use Symfony\Component\Form\FormView; | ||
17 | use Symfony\Component\OptionsResolver\OptionsResolverInterface; | ||
18 | |||
19 | class PasswordType extends AbstractType | ||
20 | { | ||
21 | /** | ||
22 | * {@inheritdoc} | ||
23 | */ | ||
24 | public function buildView(FormView $view, FormInterface $form, array $options) | ||
25 | { | ||
26 | if ($options['always_empty'] || !$form->isSubmitted()) { | ||
27 | $view->vars['value'] = ''; | ||
28 | } | ||
29 | } | ||
30 | |||
31 | /** | ||
32 | * {@inheritdoc} | ||
33 | */ | ||
34 | public function setDefaultOptions(OptionsResolverInterface $resolver) | ||
35 | { | ||
36 | $resolver->setDefaults(array( | ||
37 | 'always_empty' => true, | ||
38 | 'trim' => false, | ||
39 | )); | ||
40 | } | ||
41 | |||
42 | /** | ||
43 | * {@inheritdoc} | ||
44 | */ | ||
45 | public function getParent() | ||
46 | { | ||
47 | return 'text'; | ||
48 | } | ||
49 | |||
50 | /** | ||
51 | * {@inheritdoc} | ||
52 | */ | ||
53 | public function getName() | ||
54 | { | ||
55 | return 'password'; | ||
56 | } | ||
57 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/PercentType.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/PercentType.php new file mode 100644 index 00000000..b1df9436 --- /dev/null +++ b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/PercentType.php | |||
@@ -0,0 +1,55 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Extension\Core\Type; | ||
13 | |||
14 | use Symfony\Component\Form\AbstractType; | ||
15 | use Symfony\Component\Form\FormBuilderInterface; | ||
16 | use Symfony\Component\Form\Extension\Core\DataTransformer\PercentToLocalizedStringTransformer; | ||
17 | use Symfony\Component\OptionsResolver\OptionsResolverInterface; | ||
18 | |||
19 | class PercentType extends AbstractType | ||
20 | { | ||
21 | /** | ||
22 | * {@inheritdoc} | ||
23 | */ | ||
24 | public function buildForm(FormBuilderInterface $builder, array $options) | ||
25 | { | ||
26 | $builder->addViewTransformer(new PercentToLocalizedStringTransformer($options['precision'], $options['type'])); | ||
27 | } | ||
28 | |||
29 | /** | ||
30 | * {@inheritdoc} | ||
31 | */ | ||
32 | public function setDefaultOptions(OptionsResolverInterface $resolver) | ||
33 | { | ||
34 | $resolver->setDefaults(array( | ||
35 | 'precision' => 0, | ||
36 | 'type' => 'fractional', | ||
37 | 'compound' => false, | ||
38 | )); | ||
39 | |||
40 | $resolver->setAllowedValues(array( | ||
41 | 'type' => array( | ||
42 | 'fractional', | ||
43 | 'integer', | ||
44 | ), | ||
45 | )); | ||
46 | } | ||
47 | |||
48 | /** | ||
49 | * {@inheritdoc} | ||
50 | */ | ||
51 | public function getName() | ||
52 | { | ||
53 | return 'percent'; | ||
54 | } | ||
55 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/RadioType.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/RadioType.php new file mode 100644 index 00000000..dfa7c7d5 --- /dev/null +++ b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/RadioType.php | |||
@@ -0,0 +1,33 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Extension\Core\Type; | ||
13 | |||
14 | use Symfony\Component\Form\AbstractType; | ||
15 | |||
16 | class RadioType extends AbstractType | ||
17 | { | ||
18 | /** | ||
19 | * {@inheritdoc} | ||
20 | */ | ||
21 | public function getParent() | ||
22 | { | ||
23 | return 'checkbox'; | ||
24 | } | ||
25 | |||
26 | /** | ||
27 | * {@inheritdoc} | ||
28 | */ | ||
29 | public function getName() | ||
30 | { | ||
31 | return 'radio'; | ||
32 | } | ||
33 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/RepeatedType.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/RepeatedType.php new file mode 100644 index 00000000..9a3cd146 --- /dev/null +++ b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/RepeatedType.php | |||
@@ -0,0 +1,67 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Extension\Core\Type; | ||
13 | |||
14 | use Symfony\Component\Form\AbstractType; | ||
15 | use Symfony\Component\Form\FormBuilderInterface; | ||
16 | use Symfony\Component\Form\Extension\Core\DataTransformer\ValueToDuplicatesTransformer; | ||
17 | use Symfony\Component\OptionsResolver\OptionsResolverInterface; | ||
18 | |||
19 | class RepeatedType extends AbstractType | ||
20 | { | ||
21 | /** | ||
22 | * {@inheritdoc} | ||
23 | */ | ||
24 | public function buildForm(FormBuilderInterface $builder, array $options) | ||
25 | { | ||
26 | // Overwrite required option for child fields | ||
27 | $options['first_options']['required'] = $options['required']; | ||
28 | $options['second_options']['required'] = $options['required']; | ||
29 | |||
30 | if (!isset($options['options']['error_bubbling'])) { | ||
31 | $options['options']['error_bubbling'] = $options['error_bubbling']; | ||
32 | } | ||
33 | |||
34 | $builder | ||
35 | ->addViewTransformer(new ValueToDuplicatesTransformer(array( | ||
36 | $options['first_name'], | ||
37 | $options['second_name'], | ||
38 | ))) | ||
39 | ->add($options['first_name'], $options['type'], array_merge($options['options'], $options['first_options'])) | ||
40 | ->add($options['second_name'], $options['type'], array_merge($options['options'], $options['second_options'])) | ||
41 | ; | ||
42 | } | ||
43 | |||
44 | /** | ||
45 | * {@inheritdoc} | ||
46 | */ | ||
47 | public function setDefaultOptions(OptionsResolverInterface $resolver) | ||
48 | { | ||
49 | $resolver->setDefaults(array( | ||
50 | 'type' => 'text', | ||
51 | 'options' => array(), | ||
52 | 'first_options' => array(), | ||
53 | 'second_options' => array(), | ||
54 | 'first_name' => 'first', | ||
55 | 'second_name' => 'second', | ||
56 | 'error_bubbling' => false, | ||
57 | )); | ||
58 | } | ||
59 | |||
60 | /** | ||
61 | * {@inheritdoc} | ||
62 | */ | ||
63 | public function getName() | ||
64 | { | ||
65 | return 'repeated'; | ||
66 | } | ||
67 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/ResetType.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/ResetType.php new file mode 100644 index 00000000..cf55f7c5 --- /dev/null +++ b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/ResetType.php | |||
@@ -0,0 +1,39 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Extension\Core\Type; | ||
13 | |||
14 | use Symfony\Component\Form\AbstractType; | ||
15 | use Symfony\Component\Form\ButtonTypeInterface; | ||
16 | |||
17 | /** | ||
18 | * A reset button. | ||
19 | * | ||
20 | * @author Bernhard Schussek <bschussek@gmail.com> | ||
21 | */ | ||
22 | class ResetType extends AbstractType implements ButtonTypeInterface | ||
23 | { | ||
24 | /** | ||
25 | * {@inheritdoc} | ||
26 | */ | ||
27 | public function getParent() | ||
28 | { | ||
29 | return 'button'; | ||
30 | } | ||
31 | |||
32 | /** | ||
33 | * {@inheritdoc} | ||
34 | */ | ||
35 | public function getName() | ||
36 | { | ||
37 | return 'reset'; | ||
38 | } | ||
39 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/SearchType.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/SearchType.php new file mode 100644 index 00000000..bf82972d --- /dev/null +++ b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/SearchType.php | |||
@@ -0,0 +1,33 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Extension\Core\Type; | ||
13 | |||
14 | use Symfony\Component\Form\AbstractType; | ||
15 | |||
16 | class SearchType extends AbstractType | ||
17 | { | ||
18 | /** | ||
19 | * {@inheritdoc} | ||
20 | */ | ||
21 | public function getParent() | ||
22 | { | ||
23 | return 'text'; | ||
24 | } | ||
25 | |||
26 | /** | ||
27 | * {@inheritdoc} | ||
28 | */ | ||
29 | public function getName() | ||
30 | { | ||
31 | return 'search'; | ||
32 | } | ||
33 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/SubmitType.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/SubmitType.php new file mode 100644 index 00000000..6d160b96 --- /dev/null +++ b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/SubmitType.php | |||
@@ -0,0 +1,46 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Extension\Core\Type; | ||
13 | |||
14 | use Symfony\Component\Form\AbstractType; | ||
15 | use Symfony\Component\Form\FormInterface; | ||
16 | use Symfony\Component\Form\FormView; | ||
17 | use Symfony\Component\Form\SubmitButtonTypeInterface; | ||
18 | |||
19 | /** | ||
20 | * A submit button. | ||
21 | * | ||
22 | * @author Bernhard Schussek <bschussek@gmail.com> | ||
23 | */ | ||
24 | class SubmitType extends AbstractType implements SubmitButtonTypeInterface | ||
25 | { | ||
26 | public function buildView(FormView $view, FormInterface $form, array $options) | ||
27 | { | ||
28 | $view->vars['clicked'] = $form->isClicked(); | ||
29 | } | ||
30 | |||
31 | /** | ||
32 | * {@inheritdoc} | ||
33 | */ | ||
34 | public function getParent() | ||
35 | { | ||
36 | return 'button'; | ||
37 | } | ||
38 | |||
39 | /** | ||
40 | * {@inheritdoc} | ||
41 | */ | ||
42 | public function getName() | ||
43 | { | ||
44 | return 'submit'; | ||
45 | } | ||
46 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/TextType.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/TextType.php new file mode 100644 index 00000000..11503261 --- /dev/null +++ b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/TextType.php | |||
@@ -0,0 +1,36 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Extension\Core\Type; | ||
13 | |||
14 | use Symfony\Component\Form\AbstractType; | ||
15 | use Symfony\Component\OptionsResolver\OptionsResolverInterface; | ||
16 | |||
17 | class TextType extends AbstractType | ||
18 | { | ||
19 | /** | ||
20 | * {@inheritdoc} | ||
21 | */ | ||
22 | public function setDefaultOptions(OptionsResolverInterface $resolver) | ||
23 | { | ||
24 | $resolver->setDefaults(array( | ||
25 | 'compound' => false, | ||
26 | )); | ||
27 | } | ||
28 | |||
29 | /** | ||
30 | * {@inheritdoc} | ||
31 | */ | ||
32 | public function getName() | ||
33 | { | ||
34 | return 'text'; | ||
35 | } | ||
36 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/TextareaType.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/TextareaType.php new file mode 100644 index 00000000..0e749b15 --- /dev/null +++ b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/TextareaType.php | |||
@@ -0,0 +1,43 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Extension\Core\Type; | ||
13 | |||
14 | use Symfony\Component\Form\AbstractType; | ||
15 | use Symfony\Component\Form\FormView; | ||
16 | use Symfony\Component\Form\FormInterface; | ||
17 | |||
18 | class TextareaType extends AbstractType | ||
19 | { | ||
20 | /** | ||
21 | * {@inheritdoc} | ||
22 | */ | ||
23 | public function buildView(FormView $view, FormInterface $form, array $options) | ||
24 | { | ||
25 | $view->vars['pattern'] = null; | ||
26 | } | ||
27 | |||
28 | /** | ||
29 | * {@inheritdoc} | ||
30 | */ | ||
31 | public function getParent() | ||
32 | { | ||
33 | return 'text'; | ||
34 | } | ||
35 | |||
36 | /** | ||
37 | * {@inheritdoc} | ||
38 | */ | ||
39 | public function getName() | ||
40 | { | ||
41 | return 'textarea'; | ||
42 | } | ||
43 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/TimeType.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/TimeType.php new file mode 100644 index 00000000..d7a2a9ef --- /dev/null +++ b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/TimeType.php | |||
@@ -0,0 +1,225 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Extension\Core\Type; | ||
13 | |||
14 | use Symfony\Component\Form\AbstractType; | ||
15 | use Symfony\Component\Form\FormInterface; | ||
16 | use Symfony\Component\Form\FormBuilderInterface; | ||
17 | use Symfony\Component\Form\ReversedTransformer; | ||
18 | use Symfony\Component\Form\Exception\InvalidConfigurationException; | ||
19 | use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToStringTransformer; | ||
20 | use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToTimestampTransformer; | ||
21 | use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToArrayTransformer; | ||
22 | use Symfony\Component\Form\FormView; | ||
23 | use Symfony\Component\OptionsResolver\Options; | ||
24 | use Symfony\Component\OptionsResolver\OptionsResolverInterface; | ||
25 | |||
26 | class TimeType extends AbstractType | ||
27 | { | ||
28 | /** | ||
29 | * {@inheritdoc} | ||
30 | */ | ||
31 | public function buildForm(FormBuilderInterface $builder, array $options) | ||
32 | { | ||
33 | $parts = array('hour'); | ||
34 | $format = 'H'; | ||
35 | |||
36 | if ($options['with_seconds'] && !$options['with_minutes']) { | ||
37 | throw new InvalidConfigurationException('You can not disable minutes if you have enabled seconds.'); | ||
38 | } | ||
39 | |||
40 | if ($options['with_minutes']) { | ||
41 | $format .= ':i'; | ||
42 | $parts[] = 'minute'; | ||
43 | } | ||
44 | |||
45 | if ($options['with_seconds']) { | ||
46 | $format .= ':s'; | ||
47 | $parts[] = 'second'; | ||
48 | } | ||
49 | |||
50 | if ('single_text' === $options['widget']) { | ||
51 | $builder->addViewTransformer(new DateTimeToStringTransformer($options['model_timezone'], $options['view_timezone'], $format)); | ||
52 | } else { | ||
53 | $hourOptions = $minuteOptions = $secondOptions = array( | ||
54 | 'error_bubbling' => true, | ||
55 | ); | ||
56 | |||
57 | if ('choice' === $options['widget']) { | ||
58 | $hours = $minutes = array(); | ||
59 | |||
60 | foreach ($options['hours'] as $hour) { | ||
61 | $hours[$hour] = str_pad($hour, 2, '0', STR_PAD_LEFT); | ||
62 | } | ||
63 | |||
64 | // Only pass a subset of the options to children | ||
65 | $hourOptions['choices'] = $hours; | ||
66 | $hourOptions['empty_value'] = $options['empty_value']['hour']; | ||
67 | |||
68 | if ($options['with_minutes']) { | ||
69 | foreach ($options['minutes'] as $minute) { | ||
70 | $minutes[$minute] = str_pad($minute, 2, '0', STR_PAD_LEFT); | ||
71 | } | ||
72 | |||
73 | $minuteOptions['choices'] = $minutes; | ||
74 | $minuteOptions['empty_value'] = $options['empty_value']['minute']; | ||
75 | } | ||
76 | |||
77 | if ($options['with_seconds']) { | ||
78 | $seconds = array(); | ||
79 | |||
80 | foreach ($options['seconds'] as $second) { | ||
81 | $seconds[$second] = str_pad($second, 2, '0', STR_PAD_LEFT); | ||
82 | } | ||
83 | |||
84 | $secondOptions['choices'] = $seconds; | ||
85 | $secondOptions['empty_value'] = $options['empty_value']['second']; | ||
86 | } | ||
87 | |||
88 | // Append generic carry-along options | ||
89 | foreach (array('required', 'translation_domain') as $passOpt) { | ||
90 | $hourOptions[$passOpt] = $options[$passOpt]; | ||
91 | |||
92 | if ($options['with_minutes']) { | ||
93 | $minuteOptions[$passOpt] = $options[$passOpt]; | ||
94 | } | ||
95 | |||
96 | if ($options['with_seconds']) { | ||
97 | $secondOptions[$passOpt] = $options[$passOpt]; | ||
98 | } | ||
99 | } | ||
100 | } | ||
101 | |||
102 | $builder->add('hour', $options['widget'], $hourOptions); | ||
103 | |||
104 | if ($options['with_minutes']) { | ||
105 | $builder->add('minute', $options['widget'], $minuteOptions); | ||
106 | } | ||
107 | |||
108 | if ($options['with_seconds']) { | ||
109 | $builder->add('second', $options['widget'], $secondOptions); | ||
110 | } | ||
111 | |||
112 | $builder->addViewTransformer(new DateTimeToArrayTransformer($options['model_timezone'], $options['view_timezone'], $parts, 'text' === $options['widget'])); | ||
113 | } | ||
114 | |||
115 | if ('string' === $options['input']) { | ||
116 | $builder->addModelTransformer(new ReversedTransformer( | ||
117 | new DateTimeToStringTransformer($options['model_timezone'], $options['model_timezone'], 'H:i:s') | ||
118 | )); | ||
119 | } elseif ('timestamp' === $options['input']) { | ||
120 | $builder->addModelTransformer(new ReversedTransformer( | ||
121 | new DateTimeToTimestampTransformer($options['model_timezone'], $options['model_timezone']) | ||
122 | )); | ||
123 | } elseif ('array' === $options['input']) { | ||
124 | $builder->addModelTransformer(new ReversedTransformer( | ||
125 | new DateTimeToArrayTransformer($options['model_timezone'], $options['model_timezone'], $parts) | ||
126 | )); | ||
127 | } | ||
128 | } | ||
129 | |||
130 | /** | ||
131 | * {@inheritdoc} | ||
132 | */ | ||
133 | public function buildView(FormView $view, FormInterface $form, array $options) | ||
134 | { | ||
135 | $view->vars = array_replace($view->vars, array( | ||
136 | 'widget' => $options['widget'], | ||
137 | 'with_minutes' => $options['with_minutes'], | ||
138 | 'with_seconds' => $options['with_seconds'], | ||
139 | )); | ||
140 | |||
141 | if ('single_text' === $options['widget']) { | ||
142 | $view->vars['type'] = 'time'; | ||
143 | } | ||
144 | } | ||
145 | |||
146 | /** | ||
147 | * {@inheritdoc} | ||
148 | */ | ||
149 | public function setDefaultOptions(OptionsResolverInterface $resolver) | ||
150 | { | ||
151 | $compound = function (Options $options) { | ||
152 | return $options['widget'] !== 'single_text'; | ||
153 | }; | ||
154 | |||
155 | $emptyValue = $emptyValueDefault = function (Options $options) { | ||
156 | return $options['required'] ? null : ''; | ||
157 | }; | ||
158 | |||
159 | $emptyValueNormalizer = function (Options $options, $emptyValue) use ($emptyValueDefault) { | ||
160 | if (is_array($emptyValue)) { | ||
161 | $default = $emptyValueDefault($options); | ||
162 | |||
163 | return array_merge( | ||
164 | array('hour' => $default, 'minute' => $default, 'second' => $default), | ||
165 | $emptyValue | ||
166 | ); | ||
167 | } | ||
168 | |||
169 | return array( | ||
170 | 'hour' => $emptyValue, | ||
171 | 'minute' => $emptyValue, | ||
172 | 'second' => $emptyValue | ||
173 | ); | ||
174 | }; | ||
175 | |||
176 | $resolver->setDefaults(array( | ||
177 | 'hours' => range(0, 23), | ||
178 | 'minutes' => range(0, 59), | ||
179 | 'seconds' => range(0, 59), | ||
180 | 'widget' => 'choice', | ||
181 | 'input' => 'datetime', | ||
182 | 'with_minutes' => true, | ||
183 | 'with_seconds' => false, | ||
184 | 'model_timezone' => null, | ||
185 | 'view_timezone' => null, | ||
186 | 'empty_value' => $emptyValue, | ||
187 | // Don't modify \DateTime classes by reference, we treat | ||
188 | // them like immutable value objects | ||
189 | 'by_reference' => false, | ||
190 | 'error_bubbling' => false, | ||
191 | // If initialized with a \DateTime object, FormType initializes | ||
192 | // this option to "\DateTime". Since the internal, normalized | ||
193 | // representation is not \DateTime, but an array, we need to unset | ||
194 | // this option. | ||
195 | 'data_class' => null, | ||
196 | 'compound' => $compound, | ||
197 | )); | ||
198 | |||
199 | $resolver->setNormalizers(array( | ||
200 | 'empty_value' => $emptyValueNormalizer, | ||
201 | )); | ||
202 | |||
203 | $resolver->setAllowedValues(array( | ||
204 | 'input' => array( | ||
205 | 'datetime', | ||
206 | 'string', | ||
207 | 'timestamp', | ||
208 | 'array', | ||
209 | ), | ||
210 | 'widget' => array( | ||
211 | 'single_text', | ||
212 | 'text', | ||
213 | 'choice', | ||
214 | ), | ||
215 | )); | ||
216 | } | ||
217 | |||
218 | /** | ||
219 | * {@inheritdoc} | ||
220 | */ | ||
221 | public function getName() | ||
222 | { | ||
223 | return 'time'; | ||
224 | } | ||
225 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/TimezoneType.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/TimezoneType.php new file mode 100644 index 00000000..cd4a2ad3 --- /dev/null +++ b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/TimezoneType.php | |||
@@ -0,0 +1,86 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Extension\Core\Type; | ||
13 | |||
14 | use Symfony\Component\Form\AbstractType; | ||
15 | use Symfony\Component\OptionsResolver\OptionsResolverInterface; | ||
16 | |||
17 | class TimezoneType extends AbstractType | ||
18 | { | ||
19 | /** | ||
20 | * Stores the available timezone choices | ||
21 | * @var array | ||
22 | */ | ||
23 | private static $timezones; | ||
24 | |||
25 | /** | ||
26 | * {@inheritdoc} | ||
27 | */ | ||
28 | public function setDefaultOptions(OptionsResolverInterface $resolver) | ||
29 | { | ||
30 | $resolver->setDefaults(array( | ||
31 | 'choices' => self::getTimezones(), | ||
32 | )); | ||
33 | } | ||
34 | |||
35 | /** | ||
36 | * {@inheritdoc} | ||
37 | */ | ||
38 | public function getParent() | ||
39 | { | ||
40 | return 'choice'; | ||
41 | } | ||
42 | |||
43 | /** | ||
44 | * {@inheritdoc} | ||
45 | */ | ||
46 | public function getName() | ||
47 | { | ||
48 | return 'timezone'; | ||
49 | } | ||
50 | |||
51 | /** | ||
52 | * Returns the timezone choices. | ||
53 | * | ||
54 | * The choices are generated from the ICU function | ||
55 | * \DateTimeZone::listIdentifiers(). They are cached during a single request, | ||
56 | * so multiple timezone fields on the same page don't lead to unnecessary | ||
57 | * overhead. | ||
58 | * | ||
59 | * @return array The timezone choices | ||
60 | */ | ||
61 | public static function getTimezones() | ||
62 | { | ||
63 | if (null === static::$timezones) { | ||
64 | static::$timezones = array(); | ||
65 | |||
66 | foreach (\DateTimeZone::listIdentifiers() as $timezone) { | ||
67 | $parts = explode('/', $timezone); | ||
68 | |||
69 | if (count($parts) > 2) { | ||
70 | $region = $parts[0]; | ||
71 | $name = $parts[1].' - '.$parts[2]; | ||
72 | } elseif (count($parts) > 1) { | ||
73 | $region = $parts[0]; | ||
74 | $name = $parts[1]; | ||
75 | } else { | ||
76 | $region = 'Other'; | ||
77 | $name = $parts[0]; | ||
78 | } | ||
79 | |||
80 | static::$timezones[$region][$timezone] = str_replace('_', ' ', $name); | ||
81 | } | ||
82 | } | ||
83 | |||
84 | return static::$timezones; | ||
85 | } | ||
86 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/UrlType.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/UrlType.php new file mode 100644 index 00000000..27749b1a --- /dev/null +++ b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/UrlType.php | |||
@@ -0,0 +1,54 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Extension\Core\Type; | ||
13 | |||
14 | use Symfony\Component\Form\AbstractType; | ||
15 | use Symfony\Component\Form\FormBuilderInterface; | ||
16 | use Symfony\Component\Form\Extension\Core\EventListener\FixUrlProtocolListener; | ||
17 | use Symfony\Component\OptionsResolver\OptionsResolverInterface; | ||
18 | |||
19 | class UrlType extends AbstractType | ||
20 | { | ||
21 | /** | ||
22 | * {@inheritdoc} | ||
23 | */ | ||
24 | public function buildForm(FormBuilderInterface $builder, array $options) | ||
25 | { | ||
26 | $builder->addEventSubscriber(new FixUrlProtocolListener($options['default_protocol'])); | ||
27 | } | ||
28 | |||
29 | /** | ||
30 | * {@inheritdoc} | ||
31 | */ | ||
32 | public function setDefaultOptions(OptionsResolverInterface $resolver) | ||
33 | { | ||
34 | $resolver->setDefaults(array( | ||
35 | 'default_protocol' => 'http', | ||
36 | )); | ||
37 | } | ||
38 | |||
39 | /** | ||
40 | * {@inheritdoc} | ||
41 | */ | ||
42 | public function getParent() | ||
43 | { | ||
44 | return 'text'; | ||
45 | } | ||
46 | |||
47 | /** | ||
48 | * {@inheritdoc} | ||
49 | */ | ||
50 | public function getName() | ||
51 | { | ||
52 | return 'url'; | ||
53 | } | ||
54 | } | ||