@@ -81,20 +81,20 @@ Validator
81
81
Security
82
82
--------
83
83
84
- * The ` SecurityContextInterface ` is marked as deprecated in favor of the
85
- ` Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface ` and
84
+ * The ` SecurityContextInterface ` is marked as deprecated in favor of the
85
+ ` Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface ` and
86
86
` Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface ` .
87
87
```
88
88
isGranted => AuthorizationCheckerInterface
89
89
getToken => TokenStorageInterface
90
90
setToken => TokenStorageInterface
91
91
```
92
- The Implementations have moved too, The ` SecurityContext ` is marked as
93
- deprecated and has been split to use the ` AuthorizationCheckerInterface `
94
- and ` TokenStorage ` . This change is 100% Backwards Compatible as the SecurityContext
92
+ The Implementations have moved too, The ` SecurityContext ` is marked as
93
+ deprecated and has been split to use the ` AuthorizationCheckerInterface `
94
+ and ` TokenStorage ` . This change is 100% Backwards Compatible as the SecurityContext
95
95
delegates the methods.
96
96
97
- * The service ` security.context ` is deprecated along with the above change. Recommended
97
+ * The service ` security.context ` is deprecated along with the above change. Recommended
98
98
to use instead:
99
99
```
100
100
@security.authorization_checker => isGranted()
@@ -133,189 +133,189 @@ OptionsResolver
133
133
---------------
134
134
135
135
* The "array" type hint was removed from the ` OptionsResolverInterface ` methods
136
- ` setRequired() ` , ` setAllowedValues() ` , ` addAllowedValues() ` ,
136
+ ` setRequired() ` , ` setAllowedValues() ` , ` addAllowedValues() ` ,
137
137
` setAllowedTypes() ` and ` addAllowedTypes() ` . You must remove the type hint
138
138
from your implementations.
139
-
139
+
140
140
* The interface ` OptionsResolverInterface ` was deprecated, since
141
141
` OptionsResolver ` instances are not supposed to be shared between classes.
142
142
You should type hint against ` OptionsResolver ` instead.
143
-
143
+
144
144
Before:
145
-
145
+
146
146
``` php
147
147
protected function configureOptions(OptionsResolverInterface $resolver)
148
148
{
149
149
// ...
150
150
}
151
151
```
152
-
152
+
153
153
After:
154
-
154
+
155
155
``` php
156
156
protected function configureOptions(OptionsResolver $resolver)
157
157
{
158
158
// ...
159
159
}
160
160
```
161
-
161
+
162
162
* ` OptionsResolver::isRequired() ` now returns ` true ` if a required option has
163
163
a default value set. The new method ` isMissing() ` exhibits the old
164
164
functionality of ` isRequired() ` .
165
-
165
+
166
166
Before:
167
-
167
+
168
168
``` php
169
169
$resolver->setRequired(array('port'));
170
-
170
+
171
171
$resolver->isRequired('port');
172
172
// => true
173
-
173
+
174
174
$resolver->setDefaults(array('port' => 25));
175
-
175
+
176
176
$resolver->isRequired('port');
177
177
// => false
178
178
```
179
-
179
+
180
180
After:
181
-
181
+
182
182
``` php
183
183
$resolver->setRequired(array('port'));
184
-
184
+
185
185
$resolver->isRequired('port');
186
186
// => true
187
187
$resolver->isMissing('port');
188
188
// => true
189
-
189
+
190
190
$resolver->setDefaults(array('port' => 25));
191
-
191
+
192
192
$resolver->isRequired('port');
193
193
// => true
194
194
$resolver->isMissing('port');
195
195
// => false
196
196
```
197
-
197
+
198
198
* ` OptionsResolver::replaceDefaults() ` was deprecated. Use ` clear() ` and
199
199
` setDefaults() ` instead.
200
-
200
+
201
201
Before:
202
-
202
+
203
203
``` php
204
204
$resolver->replaceDefaults(array(
205
205
'port' => 25,
206
206
));
207
207
```
208
-
208
+
209
209
After:
210
-
210
+
211
211
``` php
212
212
$resolver->clear();
213
213
$resolver->setDefaults(array(
214
214
'port' => 25,
215
215
));
216
216
```
217
-
217
+
218
218
* ` OptionsResolver::setOptional() ` was deprecated. Use ` setDefined() ` instead.
219
-
219
+
220
220
Before:
221
-
221
+
222
222
``` php
223
223
$resolver->setOptional(array('port'));
224
224
```
225
-
225
+
226
226
After:
227
-
227
+
228
228
``` php
229
229
$resolver->setDefined('port');
230
230
```
231
-
231
+
232
232
* ` OptionsResolver::isKnown() ` was deprecated. Use ` isDefined() ` instead.
233
-
233
+
234
234
Before:
235
-
235
+
236
236
``` php
237
237
if ($resolver->isKnown('port')) {
238
238
// ...
239
239
}
240
240
```
241
-
241
+
242
242
After:
243
-
243
+
244
244
``` php
245
245
if ($resolver->isDefined('port')) {
246
246
// ...
247
247
}
248
248
```
249
-
249
+
250
250
* The methods ` setAllowedValues() ` , ` addAllowedValues() ` , ` setAllowedTypes() `
251
251
and ` addAllowedTypes() ` were changed to modify one option at a time instead
252
252
of batch processing options. The old API exists for backwards compatibility,
253
253
but will be removed in Symfony 3.0.
254
-
254
+
255
255
Before:
256
-
256
+
257
257
``` php
258
258
$resolver->setAllowedValues(array(
259
259
'method' => array('POST', 'GET'),
260
260
));
261
261
```
262
-
262
+
263
263
After:
264
-
264
+
265
265
``` php
266
266
$resolver->setAllowedValues('method', array('POST', 'GET'));
267
267
```
268
-
268
+
269
269
* The class ` Options ` was merged into ` OptionsResolver ` . If you instantiated
270
270
this class manually, you should instantiate ` OptionsResolver ` now.
271
271
` Options ` is now a marker interface implemented by ` OptionsResolver ` .
272
-
272
+
273
273
Before:
274
-
274
+
275
275
``` php
276
276
$options = new Options();
277
277
```
278
-
278
+
279
279
After:
280
-
280
+
281
281
``` php
282
282
$resolver = new OptionsResolver();
283
283
```
284
-
285
- * Normalizers for defined but unset options are not executed anymore. If you
284
+
285
+ * Normalizers for defined but unset options are not executed anymore. If you
286
286
want to have them executed, you should define a default value.
287
-
287
+
288
288
Before:
289
-
289
+
290
290
``` php
291
291
$resolver->setOptional(array('port'));
292
292
$resolver->setNormalizers(array(
293
293
'port' => function ($options, $value) {
294
294
// return normalized value
295
295
}
296
296
));
297
-
297
+
298
298
$options = $resolver->resolve($options);
299
299
```
300
-
300
+
301
301
After:
302
-
302
+
303
303
``` php
304
304
$resolver->setDefault('port', null);
305
305
$resolver->setNormalizer('port', function ($options, $value) {
306
306
// return normalized value
307
307
});
308
-
308
+
309
309
$options = $resolver->resolve($options);
310
310
```
311
-
311
+
312
312
* When undefined options are passed, ` resolve() ` now throws an
313
313
` UndefinedOptionsException ` instead of an ` InvalidOptionsException ` .
314
314
` InvalidOptionsException ` is only thrown when option values fail their
315
315
validation constraints.
316
-
316
+
317
317
Before:
318
-
318
+
319
319
``` php
320
320
$resolver->setDefaults(array(
321
321
'transport' => 'smtp',
@@ -324,16 +324,16 @@ OptionsResolver
324
324
$resolver->setAllowedTypes(array(
325
325
'port' => 'integer',
326
326
));
327
-
327
+
328
328
// throws InvalidOptionsException
329
329
$resolver->resolve(array('foo' => 'bar'));
330
-
330
+
331
331
// throws InvalidOptionsException
332
332
$resolver->resolve(array('port' => '25'));
333
333
```
334
-
334
+
335
335
After:
336
-
336
+
337
337
``` php
338
338
$resolver->setDefaults(array(
339
339
'transport' => 'smtp',
@@ -342,10 +342,10 @@ OptionsResolver
342
342
$resolver->setAllowedTypes(array(
343
343
'port' => 'integer',
344
344
));
345
-
345
+
346
346
// throws UndefinedOptionsException
347
347
$resolver->resolve(array('foo' => 'bar'));
348
-
348
+
349
349
// throws InvalidOptionsException
350
350
$resolver->resolve(array('port' => '25'));
351
351
```
@@ -357,9 +357,9 @@ The component and the bundle are new to Symfony 2.6. We encourage you
357
357
to enable the bundle in your ` app/AppKernel.php ` for the * dev* or * test*
358
358
environments. Just add this line before loading the ` WebProfilerBundle ` :
359
359
360
- ```php
361
- $bundles[] = new Symfony\Bundle\DebugBundle\DebugBundle();
362
- ```
360
+ ``` php
361
+ $bundles[] = new Symfony\Bundle\DebugBundle\DebugBundle();
362
+ ```
363
363
364
364
Then enjoy dumping variables by calling ` dump($var) ` anywhere in your PHP
365
365
and ` {% dump var %} ` or ` {{ dump(var) }} ` in Twig. Dumps are displayed
0 commit comments