|
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\Extension\Core\Type\ChoiceType; |
|
18
|
|
|
use Symfony\Component\Form\FormInterface; |
|
19
|
|
|
use Symfony\Component\Form\FormView; |
|
20
|
|
|
use Symfony\Component\OptionsResolver\OptionsResolver; |
|
21
|
|
|
use Symfony\Component\OptionsResolver\OptionsResolverInterface; |
|
22
|
|
|
|
|
23
|
|
|
class ChoiceFieldMaskType extends AbstractType |
|
24
|
|
|
{ |
|
25
|
|
|
/** |
|
26
|
|
|
* {@inheritdoc} |
|
27
|
|
|
*/ |
|
28
|
|
|
public function buildView(FormView $view, FormInterface $form, array $options): void |
|
29
|
|
|
{ |
|
30
|
|
|
$allFieldNames = []; |
|
31
|
|
|
foreach ($options['map'] as $value => $fieldNames) { |
|
32
|
|
|
foreach ($fieldNames as $fieldName) { |
|
33
|
|
|
$allFieldNames[$fieldName] = $fieldName; |
|
34
|
|
|
} |
|
35
|
|
|
} |
|
36
|
|
|
$allFieldNames = array_values($allFieldNames); |
|
37
|
|
|
|
|
38
|
|
|
$view->vars['all_fields'] = $allFieldNames; |
|
39
|
|
|
$view->vars['map'] = $options['map']; |
|
40
|
|
|
parent::buildView($view, $form, $options); |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* NEXT_MAJOR: remove this method. |
|
45
|
|
|
*/ |
|
46
|
|
|
public function setDefaultOptions(OptionsResolverInterface $resolver): void |
|
47
|
|
|
{ |
|
48
|
|
|
$this->configureOptions($resolver); |
|
|
|
|
|
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* {@inheritdoc} |
|
53
|
|
|
*/ |
|
54
|
|
|
public function configureOptions(OptionsResolver $resolver): void |
|
55
|
|
|
{ |
|
56
|
|
|
$resolver->setDefaults([ |
|
57
|
|
|
'map' => [], |
|
58
|
|
|
]); |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* {@inheritdoc} |
|
63
|
|
|
*/ |
|
64
|
|
|
public function getParent() |
|
65
|
|
|
{ |
|
66
|
|
|
return ChoiceType::class; |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
/** |
|
70
|
|
|
* NEXT_MAJOR: remove this method. |
|
71
|
|
|
*/ |
|
72
|
|
|
public function getName() |
|
73
|
|
|
{ |
|
74
|
|
|
return $this->getBlockPrefix(); |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
/** |
|
78
|
|
|
* {@inheritdoc} |
|
79
|
|
|
*/ |
|
80
|
|
|
public function getBlockPrefix() |
|
81
|
|
|
{ |
|
82
|
|
|
return 'choice_field_mask'; |
|
83
|
|
|
} |
|
84
|
|
|
} |
|
85
|
|
|
|
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: