1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
/* |
6
|
|
|
* This file is part of the Sonata Project package. |
7
|
|
|
* |
8
|
|
|
* (c) Thomas Rabaix <[email protected]> |
9
|
|
|
* |
10
|
|
|
* For the full copyright and license information, please view the LICENSE |
11
|
|
|
* file that was distributed with this source code. |
12
|
|
|
*/ |
13
|
|
|
|
14
|
|
|
namespace Sonata\DoctrinePHPCRAdminBundle\Form\Type; |
15
|
|
|
|
16
|
|
|
use Symfony\Component\Form\AbstractType; |
17
|
|
|
use Symfony\Component\Form\FormInterface; |
18
|
|
|
use Symfony\Component\Form\FormView; |
19
|
|
|
use Symfony\Component\OptionsResolver\OptionsResolver; |
20
|
|
|
use Symfony\Component\OptionsResolver\OptionsResolverInterface; |
21
|
|
|
|
22
|
|
|
class ChoiceFieldMaskType extends AbstractType |
23
|
|
|
{ |
24
|
|
|
/** |
25
|
|
|
* {@inheritdoc} |
26
|
|
|
*/ |
27
|
|
|
public function buildView(FormView $view, FormInterface $form, array $options): void |
28
|
|
|
{ |
29
|
|
|
$allFieldNames = []; |
30
|
|
|
foreach ($options['map'] as $value => $fieldNames) { |
31
|
|
|
foreach ($fieldNames as $fieldName) { |
32
|
|
|
$allFieldNames[$fieldName] = $fieldName; |
33
|
|
|
} |
34
|
|
|
} |
35
|
|
|
$allFieldNames = array_values($allFieldNames); |
36
|
|
|
|
37
|
|
|
$view->vars['all_fields'] = $allFieldNames; |
38
|
|
|
$view->vars['map'] = $options['map']; |
39
|
|
|
parent::buildView($view, $form, $options); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* {@inheritdoc} |
44
|
|
|
* |
45
|
|
|
* @todo Remove when Symfony <2.8 is no longer supported |
46
|
|
|
*/ |
47
|
|
|
public function setDefaultOptions(OptionsResolverInterface $resolver): void |
48
|
|
|
{ |
49
|
|
|
$this->configureOptions($resolver); |
|
|
|
|
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* {@inheritdoc} |
54
|
|
|
*/ |
55
|
|
|
public function configureOptions(OptionsResolver $resolver): void |
56
|
|
|
{ |
57
|
|
|
$resolver->setDefaults([ |
58
|
|
|
'map' => [], |
59
|
|
|
]); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* {@inheritdoc} |
64
|
|
|
*/ |
65
|
|
|
public function getParent() |
66
|
|
|
{ |
67
|
|
|
return 'choice'; |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* {@inheritdoc} |
72
|
|
|
* |
73
|
|
|
* @todo Remove when Symfony <2.8 is no longer supported |
74
|
|
|
*/ |
75
|
|
|
public function getName() |
76
|
|
|
{ |
77
|
|
|
return $this->getBlockPrefix(); |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* {@inheritdoc} |
82
|
|
|
*/ |
83
|
|
|
public function getBlockPrefix() |
84
|
|
|
{ |
85
|
|
|
return 'choice_field_mask'; |
86
|
|
|
} |
87
|
|
|
} |
88
|
|
|
|
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: