You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feature #15025 [2.8] [Form] Rename CollectionType options for entries (WouterJ)
This PR was merged into the 2.8 branch.
Discussion
----------
[2.8] [Form] Rename CollectionType options for entries
Description
---
Replaces #13820 for the 2.8 branch.
Original description:
> `type` and `options` are extremely generic. Prefixing them with `entry_` makes it clear what they are configuring.
> About the property deprecation it is the same story as symfony/symfony#13717 and I don't know which direction you want me to go.
I've tried to apply the comments in the previous PR, but got a bit lost in the normalizers/default closure stuff. I hope I did everything correctly, but please review :)
PR Info Table
---
| Q | A
| ------------- | ---
| Bug fix? | no
| New feature? | yes
| BC breaks? | no
| Deprecations? | yes
| Tests pass? | yes
| Fixed tickets | #7831
| License | MIT
| Doc PR | symfony/symfony-docs#5051
Commits
-------
942a237 Rename CollectionType options for entries
$optionsNormalizer = function (Options$options, $value) {
79
+
$entryOptionsNormalizer = function (Options$options, $value) {
80
80
$value['block_name'] = 'entry';
81
81
82
82
return$value;
83
83
};
84
+
$optionsNormalizer = function (Options$options, $value) use ($entryOptionsNormalizer) {
85
+
if (null !== $value) {
86
+
@trigger_error('The form option "options" is deprecated since version 2.8 and will be removed in 3.0. Use "entry_options" instead.', E_USER_DEPRECATED);
87
+
}
88
+
89
+
return$entryOptionsNormalizer($options, $value);
90
+
};
91
+
$typeNormalizer = function (Options$options, $value) {
92
+
if (null !== $value) {
93
+
@trigger_error('The form option "type" is deprecated since version 2.8 and will be removed in 3.0. Use "entry_type" instead.', E_USER_DEPRECATED);
94
+
}
95
+
};
96
+
$entryType = function (Options$options) {
97
+
if (null !== $options['type']) {
98
+
return$options['type'];
99
+
}
100
+
101
+
return__NAMESPACE__.'\TextType';
102
+
};
103
+
$entryOptions = function (Options$options) {
104
+
if (1 === count($options['options']) && isset($options['block_name'])) {
105
+
returnarray();
106
+
}
107
+
108
+
return$options['options'];
109
+
};
84
110
85
111
$resolver->setDefaults(array(
86
112
'allow_add' => false,
87
113
'allow_delete' => false,
88
114
'prototype' => true,
89
115
'prototype_data' => null,
90
116
'prototype_name' => '__name__',
91
-
'type' => __NAMESPACE__.'\TextType',
92
-
'options' => array(),
117
+
// deprecated as of Symfony 2.8, to be removed in Symfony 3.0. Use entry_type instead
118
+
'type' => null,
119
+
// deprecated as of Symfony 2.8, to be removed in Symfony 3.0. Use entry_options instead
0 commit comments