From 37fa93428e8972c84631412ce5d6128f2d0a1fbe Mon Sep 17 00:00:00 2001 From: Guilhem Niot Date: Sun, 31 May 2020 15:55:52 +0200 Subject: [PATCH 1/2] Improve deprecations DX --- DependencyInjection/Configuration.php | 45 +++++++++++---------------- Resources/config/routing.xml | 12 +++---- 2 files changed, 25 insertions(+), 32 deletions(-) diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index 099102eae..7aa254c75 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -463,44 +463,37 @@ private function addExceptionSection(ArrayNodeDefinition $rootNode) ->fixXmlConfig('message', 'messages') ->addDefaultsIfNotSet() ->canBeEnabled() + ->validate() + ->always() + ->then(function ($v) { + if (!$v['enabled']) { + return $v; + } + + if ($v['exception_listener']) { + @trigger_error('Enabling the "fos_rest.exception.exception_listener" option is deprecated since FOSRestBundle 2.8.', E_USER_DEPRECATED); + } + if ($v['serialize_exceptions']) { + @trigger_error('Enabling the "fos_rest.exception.serialize_exceptions" option is deprecated since FOSRestBundle 2.8.', E_USER_DEPRECATED); + } + + return $v; + }) + ->end() ->children() ->booleanNode('map_exception_codes') ->defaultFalse() ->info('Enables an event listener that maps exception codes to response status codes based on the map configured with the "fos_rest.exception.codes" option.') ->end() ->booleanNode('exception_listener') - ->defaultValue(function () { - @trigger_error('Enabling the "fos_rest.exception.exception_listener" option is deprecated since FOSRestBundle 2.8.', E_USER_DEPRECATED); - - return true; - }) - ->beforeNormalization() - ->ifTrue() - ->then(function ($v) { - @trigger_error('Enabling the "fos_rest.exception.exception_listener" option is deprecated since FOSRestBundle 2.8.', E_USER_DEPRECATED); - - return $v; - }) - ->end() + ->defaultTrue() ->end() ->scalarNode('exception_controller') ->defaultNull() ->setDeprecated('The "%path%.%node%" option is deprecated since FOSRestBundle 2.8.') ->end() ->booleanNode('serialize_exceptions') - ->defaultValue(function () { - @trigger_error('Enabling the "fos_rest.exception.serialize_exceptions" option is deprecated since FOSRestBundle 2.8.', E_USER_DEPRECATED); - - return true; - }) - ->beforeNormalization() - ->ifTrue() - ->then(function ($v) { - @trigger_error('Enabling the "fos_rest.exception.serialize_exceptions" option is deprecated since FOSRestBundle 2.8.', E_USER_DEPRECATED); - - return $v; - }) - ->end() + ->defaultTrue() ->end() ->enumNode('flatten_exception_format') ->defaultValue('legacy') diff --git a/Resources/config/routing.xml b/Resources/config/routing.xml index d228ee344..6902c7ed2 100644 --- a/Resources/config/routing.xml +++ b/Resources/config/routing.xml @@ -10,18 +10,18 @@ - The %service_id% service is deprecated since FOSRestBundle 2.8. + The %service_id% service is deprecated since FOSRestBundle 2.8. You can disable it by setting the config `fos_rest.routing_loader.enabled` to `false`. - The %service_id% service is deprecated since FOSRestBundle 2.8. + The %service_id% service is deprecated since FOSRestBundle 2.8. You can disable it by setting the config `fos_rest.routing_loader.enabled` to `false`. - The %service_id% service is deprecated since FOSRestBundle 2.8. + The %service_id% service is deprecated since FOSRestBundle 2.8. You can disable it by setting the config `fos_rest.routing_loader.enabled` to `false`. @@ -31,7 +31,7 @@ - The %service_id% service is deprecated since FOSRestBundle 2.8. + The %service_id% service is deprecated since FOSRestBundle 2.8. You can disable it by setting the config `fos_rest.routing_loader.enabled` to `false`. @@ -41,7 +41,7 @@ - The %service_id% service is deprecated since FOSRestBundle 2.8. + The %service_id% service is deprecated since FOSRestBundle 2.8. You can disable it by setting the config `fos_rest.routing_loader.enabled` to `false`. @@ -57,7 +57,7 @@ - The %service_id% service is deprecated since FOSRestBundle 2.8. + The %service_id% service is deprecated since FOSRestBundle 2.8. You can disable it by setting the config `fos_rest.routing_loader.enabled` to `false`. From b7e7ee7002ff766949196274e10c8e14b0ad6b3d Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Sat, 30 May 2020 09:09:54 +0200 Subject: [PATCH 2/2] clean up the readme file --- README.md | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 69eb5fbfd..7c8cee65c 100644 --- a/README.md +++ b/README.md @@ -5,10 +5,12 @@ This bundle provides various tools to rapidly develop RESTful API's & applications with Symfony. Features include: - A View layer to enable output and format agnostic Controllers -- A custom route loader to generate url's following REST conventions - Accept header format negotiation including handling for custom mime types - RESTful decoding of HTTP request body and Accept headers -- Exception controller for sending appropriate HTTP status codes +- Map exception codes to HTTP response status codes +- A serializer error renderer that returns exceptions and errors in a format + compatible with RFC 7807 using the Symfony Serializer component or the + JMS Serializer [![Build Status](https://travis-ci.org/FriendsOfSymfony/FOSRestBundle.svg?branch=master)](https://travis-ci.org/FriendsOfSymfony/FOSRestBundle) [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/FriendsOfSymfony/FOSRestBundle/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/FriendsOfSymfony/FOSRestBundle/?branch=master) @@ -17,18 +19,12 @@ applications with Symfony. Features include: [![Latest Stable Version](https://poser.pugx.org/FriendsOfSymfony/rest-bundle/v/stable.svg)](https://packagist.org/packages/FriendsOfSymfony/rest-bundle) [![SensioLabsInsight](https://insight.sensiolabs.com/projects/0be23389-2e85-49cf-b333-caaa36d11c62/mini.png)](https://insight.sensiolabs.com/projects/0be23389-2e85-49cf-b333-caaa36d11c62) -Note ----- - -FOSRestBundle 1.x is no longer maintained, 1.8 only receives security fixes. Please upgrade to FOSRestBundle 2.x as soon as possible. - Documentation ------------- [Read the Documentation](http://symfony.com/doc/master/bundles/FOSRestBundle/index.html) -Please see the [UPGRADING-2.0.md](https://github.com/FriendsOfSymfony/FOSRestBundle/blob/master/UPGRADING-2.0.md) for any -relevant instructions when upgrading to a newer version. +Please see the upgrade files (`UPGRADING-X.X.md`) for any relevant instructions when upgrading to a newer version. Installation ------------