diff options
author | Nicolas LÅ“uillet <nicolas.loeuillet@gmail.com> | 2013-08-04 17:50:34 +0200 |
---|---|---|
committer | Nicolas LÅ“uillet <nicolas.loeuillet@gmail.com> | 2013-08-04 17:50:34 +0200 |
commit | 46b77928f746a4231d064774b5b67fd892c7ce86 (patch) | |
tree | e3ea690b3f0def1744ddae758923cf92171ef985 /vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/CollectionType.php | |
parent | 68abd9c71b1d2f7bb2e9d21819584d1d15005b25 (diff) | |
download | wallabag-46b77928f746a4231d064774b5b67fd892c7ce86.tar.gz wallabag-46b77928f746a4231d064774b5b67fd892c7ce86.tar.zst wallabag-46b77928f746a4231d064774b5b67fd892c7ce86.zip |
rm vendor
Diffstat (limited to 'vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/CollectionType.php')
-rw-r--r-- | vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/CollectionType.php | 103 |
1 files changed, 0 insertions, 103 deletions
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 deleted file mode 100644 index 0cb3af1b..00000000 --- a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/CollectionType.php +++ /dev/null | |||
@@ -1,103 +0,0 @@ | |||
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 | } | ||