diff --git a/UPGRADE-2.6.md b/UPGRADE-2.6.md index 75002bc5c5..e01a1dc3ca 100644 --- a/UPGRADE-2.6.md +++ b/UPGRADE-2.6.md @@ -81,20 +81,20 @@ Validator Security -------- - * The `SecurityContextInterface` is marked as deprecated in favor of the - `Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface` and + * The `SecurityContextInterface` is marked as deprecated in favor of the + `Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface` and `Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface`. ``` isGranted => AuthorizationCheckerInterface getToken => TokenStorageInterface setToken => TokenStorageInterface ``` - The Implementations have moved too, The `SecurityContext` is marked as - deprecated and has been split to use the `AuthorizationCheckerInterface` - and `TokenStorage`. This change is 100% Backwards Compatible as the SecurityContext + The Implementations have moved too, The `SecurityContext` is marked as + deprecated and has been split to use the `AuthorizationCheckerInterface` + and `TokenStorage`. This change is 100% Backwards Compatible as the SecurityContext delegates the methods. - * The service `security.context` is deprecated along with the above change. Recommended + * The service `security.context` is deprecated along with the above change. Recommended to use instead: ``` @security.authorization_checker => isGranted() @@ -133,160 +133,160 @@ OptionsResolver --------------- * The "array" type hint was removed from the `OptionsResolverInterface` methods - `setRequired()`, `setAllowedValues()`, `addAllowedValues()`, + `setRequired()`, `setAllowedValues()`, `addAllowedValues()`, `setAllowedTypes()` and `addAllowedTypes()`. You must remove the type hint from your implementations. - + * The interface `OptionsResolverInterface` was deprecated, since `OptionsResolver` instances are not supposed to be shared between classes. You should type hint against `OptionsResolver` instead. - + Before: - + ```php protected function configureOptions(OptionsResolverInterface $resolver) { // ... } ``` - + After: - + ```php protected function configureOptions(OptionsResolver $resolver) { // ... } ``` - + * `OptionsResolver::isRequired()` now returns `true` if a required option has a default value set. The new method `isMissing()` exhibits the old functionality of `isRequired()`. - + Before: - + ```php $resolver->setRequired(array('port')); - + $resolver->isRequired('port'); // => true - + $resolver->setDefaults(array('port' => 25)); - + $resolver->isRequired('port'); // => false ``` - + After: - + ```php $resolver->setRequired(array('port')); - + $resolver->isRequired('port'); // => true $resolver->isMissing('port'); // => true - + $resolver->setDefaults(array('port' => 25)); - + $resolver->isRequired('port'); // => true $resolver->isMissing('port'); // => false ``` - + * `OptionsResolver::replaceDefaults()` was deprecated. Use `clear()` and `setDefaults()` instead. - + Before: - + ```php $resolver->replaceDefaults(array( 'port' => 25, )); ``` - + After: - + ```php $resolver->clear(); $resolver->setDefaults(array( 'port' => 25, )); ``` - + * `OptionsResolver::setOptional()` was deprecated. Use `setDefined()` instead. - + Before: - + ```php $resolver->setOptional(array('port')); ``` - + After: - + ```php $resolver->setDefined('port'); ``` - + * `OptionsResolver::isKnown()` was deprecated. Use `isDefined()` instead. - + Before: - + ```php if ($resolver->isKnown('port')) { // ... } ``` - + After: - + ```php if ($resolver->isDefined('port')) { // ... } ``` - + * The methods `setAllowedValues()`, `addAllowedValues()`, `setAllowedTypes()` and `addAllowedTypes()` were changed to modify one option at a time instead of batch processing options. The old API exists for backwards compatibility, but will be removed in Symfony 3.0. - + Before: - + ```php $resolver->setAllowedValues(array( 'method' => array('POST', 'GET'), )); ``` - + After: - + ```php $resolver->setAllowedValues('method', array('POST', 'GET')); ``` - + * The class `Options` was merged into `OptionsResolver`. If you instantiated this class manually, you should instantiate `OptionsResolver` now. `Options` is now a marker interface implemented by `OptionsResolver`. - + Before: - + ```php $options = new Options(); ``` - + After: - + ```php $resolver = new OptionsResolver(); ``` - - * Normalizers for defined but unset options are not executed anymore. If you + + * Normalizers for defined but unset options are not executed anymore. If you want to have them executed, you should define a default value. - + Before: - + ```php $resolver->setOptional(array('port')); $resolver->setNormalizers(array( @@ -294,28 +294,28 @@ OptionsResolver // return normalized value } )); - + $options = $resolver->resolve($options); ``` - + After: - + ```php $resolver->setDefault('port', null); $resolver->setNormalizer('port', function ($options, $value) { // return normalized value }); - + $options = $resolver->resolve($options); ``` - + * When undefined options are passed, `resolve()` now throws an `UndefinedOptionsException` instead of an `InvalidOptionsException`. `InvalidOptionsException` is only thrown when option values fail their validation constraints. - + Before: - + ```php $resolver->setDefaults(array( 'transport' => 'smtp', @@ -324,16 +324,16 @@ OptionsResolver $resolver->setAllowedTypes(array( 'port' => 'integer', )); - + // throws InvalidOptionsException $resolver->resolve(array('foo' => 'bar')); - + // throws InvalidOptionsException $resolver->resolve(array('port' => '25')); ``` - + After: - + ```php $resolver->setDefaults(array( 'transport' => 'smtp', @@ -342,10 +342,10 @@ OptionsResolver $resolver->setAllowedTypes(array( 'port' => 'integer', )); - + // throws UndefinedOptionsException $resolver->resolve(array('foo' => 'bar')); - + // throws InvalidOptionsException $resolver->resolve(array('port' => '25')); ``` @@ -357,9 +357,9 @@ The component and the bundle are new to Symfony 2.6. We encourage you to enable the bundle in your `app/AppKernel.php` for the *dev* or *test* environments. Just add this line before loading the `WebProfilerBundle`: - ```php - $bundles[] = new Symfony\Bundle\DebugBundle\DebugBundle(); - ``` +```php +$bundles[] = new Symfony\Bundle\DebugBundle\DebugBundle(); +``` Then enjoy dumping variables by calling `dump($var)` anywhere in your PHP and `{% dump var %}` or `{{ dump(var) }}` in Twig. Dumps are displayed