1 | <?php |
||
24 | final class SelectAttributeType extends AbstractType |
||
25 | { |
||
26 | /** |
||
27 | * {@inheritdoc} |
||
28 | */ |
||
29 | public function getParent() |
||
33 | |||
34 | /** |
||
35 | * {@inheritdoc} |
||
36 | */ |
||
37 | public function buildForm(FormBuilderInterface $builder, array $options) |
||
60 | |||
61 | /** |
||
62 | * {@inheritdoc} |
||
63 | */ |
||
64 | public function configureOptions(OptionsResolver $resolver) |
||
65 | { |
||
66 | $resolver |
||
67 | ->setRequired('configuration') |
||
68 | ->setDefault('placeholder', 'sylius.form.attribute_type_configuration.select.choose') |
||
69 | ->setNormalizer('choices', function(Options $options){ |
||
70 | if (is_array($options['configuration']) |
||
71 | && isset($options['configuration']['choices']) |
||
72 | && is_array($options['configuration']['choices'])) { |
||
73 | $choices = array_flip($options['configuration']['choices']); |
||
74 | ksort($choices); |
||
75 | |||
76 | return $choices; |
||
77 | } |
||
78 | |||
79 | return []; |
||
80 | }) |
||
81 | ->setNormalizer('multiple', function(Options $options){ |
||
82 | if (is_array($options['configuration']) && isset($options['configuration']['multiple'])) { |
||
83 | return $options['configuration']['multiple']; |
||
84 | } |
||
85 | |||
86 | return false; |
||
87 | }) |
||
88 | ; |
||
89 | } |
||
90 | |||
91 | /** |
||
92 | * {@inheritdoc} |
||
93 | */ |
||
94 | public function getBlockPrefix() |
||
98 | } |
||
99 |