1 | <?php |
||
30 | class VideoUploaderExtension extends AbstractTypeExtension |
||
31 | { |
||
32 | /** |
||
33 | * The url generator |
||
34 | * @var UrlGeneratorInterface |
||
35 | */ |
||
36 | private $urlGenerator; |
||
37 | |||
38 | /** |
||
39 | * General options to configure the display of widget components |
||
40 | * @var array |
||
41 | */ |
||
42 | private $defaultOptions; |
||
43 | |||
44 | /** |
||
45 | * Constructor. |
||
46 | * |
||
47 | * @param UrlGeneratorInterface $urlGenerator The url generator |
||
48 | * @param array $defaultOptions Default display options for widget objects |
||
49 | */ |
||
50 | 17 | public function __construct(UrlGeneratorInterface $urlGenerator, array $defaultOptions) |
|
59 | |||
60 | /** |
||
61 | * {@inheritDoc} |
||
62 | */ |
||
63 | 17 | public function getExtendedType() |
|
72 | |||
73 | /** |
||
74 | * {@inheritDoc} |
||
75 | */ |
||
76 | 17 | public function setDefaultOptions(OptionsResolverInterface $resolver) |
|
85 | |||
86 | /** |
||
87 | * {@inheritDoc} |
||
88 | */ |
||
89 | 17 | public function configureOptions(OptionsResolver $resolver) |
|
90 | { |
||
91 | 17 | $resolver->setDefaults(array( |
|
92 | 17 | 'panda_widget' => false, |
|
93 | 17 | 'panda_widget_version' => 2, |
|
94 | 17 | 'cloud' => null, |
|
95 | 17 | )); |
|
96 | 17 | $resolver->setDefaults($this->defaultOptions); |
|
97 | |||
98 | 17 | $cloudNormalizer = function (Options $options, $cloud) { |
|
99 | 16 | if (!$options['panda_widget']) { |
|
100 | 4 | return null; |
|
101 | } |
||
102 | |||
103 | 12 | if (null === $cloud) { |
|
104 | 1 | throw new InvalidOptionsException('The "cloud" option is required when enabling the panda widget.'); |
|
105 | } |
||
106 | |||
107 | 11 | return $cloud; |
|
108 | 17 | }; |
|
109 | |||
110 | 17 | if (method_exists($resolver, 'setNormalizer')) { |
|
111 | 17 | $resolver->setNormalizer('cloud', $cloudNormalizer); |
|
112 | 17 | $resolver->setAllowedValues('panda_widget', array(true, false, 'yes', 'no')); |
|
113 | 17 | $resolver->setAllowedValues('panda_widget_version', array(1, 2)); |
|
114 | 17 | $resolver->setAllowedTypes('cancel_button', 'bool'); |
|
115 | 17 | $resolver->setAllowedTypes('cloud', array('null', 'string')); |
|
116 | 17 | $resolver->setAllowedTypes('multiple_files', 'bool'); |
|
117 | 17 | $resolver->setAllowedTypes('panda_widget', array('bool', 'string')); |
|
118 | 17 | $resolver->setAllowedTypes('progress_bar', 'bool'); |
|
119 | 17 | } else { |
|
120 | $resolver->setNormalizers(array('cloud' => $cloudNormalizer)); |
||
121 | $resolver->setAllowedValues( |
||
122 | array("panda_widget" => array(true, false, 'yes', 'no')), |
||
|
|||
123 | array("panda_widget_version" => array(1, 2)) |
||
124 | ); |
||
125 | $resolver->setAllowedTypes(array( |
||
126 | 'cancel_button' => 'bool', |
||
127 | 'cloud' => array('null', 'string'), |
||
128 | 'multiple_files' => 'bool', |
||
129 | 'panda_widget' => array('bool', 'string'), |
||
130 | 'progress_bar' => 'bool', |
||
131 | )); |
||
132 | } |
||
133 | 17 | } |
|
134 | |||
135 | /** |
||
136 | * {@inheritDoc} |
||
137 | */ |
||
138 | 12 | public function buildView(FormView $view, FormInterface $form, array $options) |
|
176 | } |
||
177 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: