Skip to content

Commit

Permalink
remove the template related exception controllers
Browse files Browse the repository at this point in the history
  • Loading branch information
xabbuh committed Feb 5, 2020
1 parent df9ba53 commit a360f26
Show file tree
Hide file tree
Showing 20 changed files with 2 additions and 256 deletions.
53 changes: 0 additions & 53 deletions Controller/TemplatingExceptionController.php

This file was deleted.

102 changes: 0 additions & 102 deletions Controller/TwigExceptionController.php

This file was deleted.

48 changes: 0 additions & 48 deletions DependencyInjection/Compiler/TwigExceptionPass.php

This file was deleted.

16 changes: 1 addition & 15 deletions DependencyInjection/Configuration.php
Expand Up @@ -431,21 +431,7 @@ private function addExceptionSection(ArrayNodeDefinition $rootNode)
->addDefaultsIfNotSet()
->canBeEnabled()
->children()
->scalarNode('exception_controller')
->defaultValue(static function () {
@trigger_error('Not setting the "fos_rest.exception.exception_controller" configuration option is deprecated since FOSRestBundle 2.8. Its default value will be set to "fos_rest.exception.controller::showAction" in 3.0.', E_USER_DEPRECATED);

return null;
})
->validate()
->ifTrue(static function ($v) { return null === $v; })
->then(static function ($v) {
@trigger_error('Not setting the "fos_rest.exception.exception_controller" configuration option is deprecated since FOSRestBundle 2.8. Its default value will be set to "fos_rest.exception.controller::showAction" in 3.0.', E_USER_DEPRECATED);

return $v;
})
->end()
->end()
->scalarNode('exception_controller')->defaultValue('fos_rest.exception.controller::showAction')->end()
->scalarNode('service')->defaultNull()->end()
->arrayNode('codes')
->useAttributeAsKey('name')
Expand Down
4 changes: 1 addition & 3 deletions DependencyInjection/FOSRestExtension.php
Expand Up @@ -351,9 +351,7 @@ private function loadException(array $config, XmlFileLoader $loader, ContainerBu
$service->clearTag('kernel.event_subscriber');
}

$controller = $config['exception']['exception_controller'] ?? null;

$container->getDefinition('fos_rest.exception_listener')->replaceArgument(0, $controller);
$container->getDefinition('fos_rest.exception_listener')->replaceArgument(0, $config['exception']['exception_controller']);

$container->getDefinition('fos_rest.exception.codes_map')
->replaceArgument(0, $config['exception']['codes']);
Expand Down
3 changes: 0 additions & 3 deletions FOSRestBundle.php
Expand Up @@ -17,7 +17,6 @@
use FOS\RestBundle\DependencyInjection\Compiler\JMSHandlersPass;
use FOS\RestBundle\DependencyInjection\Compiler\FormatListenerRulesPass;
use FOS\RestBundle\DependencyInjection\Compiler\SerializerConfigurationPass;
use FOS\RestBundle\DependencyInjection\Compiler\TwigExceptionPass;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Compiler\PassConfig;
use Symfony\Component\HttpKernel\Bundle\Bundle;
Expand All @@ -38,8 +37,6 @@ public function build(ContainerBuilder $container)
$container->addCompilerPass(new SerializerConfigurationPass());
$container->addCompilerPass(new ConfigurationCheckPass(), PassConfig::TYPE_BEFORE_OPTIMIZATION, -10);
$container->addCompilerPass(new FormatListenerRulesPass());
// must run after \Symfony\Bundle\TwigBundle\DependencyInjection\Compiler\ExtensionPass which removes the templating.engine.twig service when templating is not enabled
$container->addCompilerPass(new TwigExceptionPass(), PassConfig::TYPE_BEFORE_REMOVING, -10);
$container->addCompilerPass(new JMSFormErrorHandlerPass());
$container->addCompilerPass(new JMSHandlersPass(), PassConfig::TYPE_BEFORE_REMOVING, -10);
$container->addCompilerPass(new HandlerRegistryDecorationPass(), PassConfig::TYPE_AFTER_REMOVING);
Expand Down
5 changes: 0 additions & 5 deletions Resources/config/exception_listener.xml
Expand Up @@ -19,11 +19,6 @@
<argument /><!-- show exception -->
</service>

<service id="fos_rest.exception.twig_controller" class="FOS\RestBundle\Controller\TwigExceptionController" parent="fos_rest.exception.controller">
<argument type="service" id="templating.engine.twig" />
<deprecated>The "%service_id%" service is deprecated since FOSRestBundle 2.8.</deprecated>
</service>

<service id="fos_rest.exception.codes_map" class="FOS\RestBundle\Util\ExceptionValueMap" public="false">
<argument type="collection"/> <!-- exception codes -->
</service>
Expand Down
9 changes: 0 additions & 9 deletions Resources/doc/4-exception-controller-support.rst
Expand Up @@ -21,15 +21,6 @@ configuration:

The FOSRestBundle ExceptionController is executed before the one of the TwigBundle.

.. note::

FOSRestBundle defines two services for exception rendering, by default it
configures ``fos_rest.exception.controller`` which only supports rendering
via a serializer. In case no explicit controller is configured by the user
and TwigBundle is detected it will automatically configure
``fos_rest.exception.twig_controller`` which additionally also supports
rendering via Twig.

To map Exception classes to HTTP response status codes an *exception map* may
be configured, where the keys match a fully qualified class name and the values
are either an integer HTTP response status code or a string matching a class
Expand Down
1 change: 0 additions & 1 deletion Tests/Functional/app/AllowedMethodsListener/config.yml
@@ -1,6 +1,5 @@
imports:
- { resource: ../config/default.yml }
- { resource: ../config/default.php }
- { resource: ../config/sensio_framework_extra.yml }

framework:
Expand Down
1 change: 0 additions & 1 deletion Tests/Functional/app/Configuration/config.yml
@@ -1,6 +1,5 @@
imports:
- { resource: ../config/default.yml }
- { resource: ../config/default.php }
- { resource: ../config/sensio_framework_extra.yml }
- { resource: security.php }

Expand Down
1 change: 0 additions & 1 deletion Tests/Functional/app/Debug/config.yml
@@ -1,6 +1,5 @@
imports:
- { resource: ../config/default.yml }
- { resource: ../config/default.php }
- { resource: ../config/exception_listener.yml }

fos_rest:
Expand Down
1 change: 0 additions & 1 deletion Tests/Functional/app/JMSSerializer/config.yml
@@ -1,6 +1,5 @@
imports:
- { resource: ../config/default.yml }
- { resource: ../config/default.php }
- { resource: ../config/exception_listener.yml }

fos_rest:
Expand Down
1 change: 0 additions & 1 deletion Tests/Functional/app/ParamFetcher/config.yml
@@ -1,6 +1,5 @@
imports:
- { resource: ../config/default.yml }
- { resource: ../config/default.php }
- { resource: ../config/sensio_framework_extra.yml }

parameters:
Expand Down
1 change: 0 additions & 1 deletion Tests/Functional/app/RequestBodyParamConverter/config.yml
@@ -1,6 +1,5 @@
imports:
- { resource: ../config/default.yml }
- { resource: ../config/default.php }
- { resource: ../config/sensio_framework_extra.yml }

framework:
Expand Down
@@ -1,6 +1,5 @@
imports:
- { resource: ../config/default.yml }
- { resource: ../config/default.php }
- { resource: ../config/sensio_framework_extra.yml }

framework:
Expand Down
1 change: 0 additions & 1 deletion Tests/Functional/app/Routing/config.yml
@@ -1,6 +1,5 @@
imports:
- { resource: ../config/default.yml }
- { resource: ../config/default.php }

framework:
serializer:
Expand Down
1 change: 0 additions & 1 deletion Tests/Functional/app/Serializer/config.yml
@@ -1,6 +1,5 @@
imports:
- { resource: ../config/default.yml }
- { resource: ../config/default.php }
- { resource: ../config/exception_listener.yml }

framework:
Expand Down
1 change: 0 additions & 1 deletion Tests/Functional/app/Version/config.yml
@@ -1,6 +1,5 @@
imports:
- { resource: ../config/default.yml }
- { resource: ../config/default.php }
- { resource: ../config/sensio_framework_extra.yml }

framework:
Expand Down
1 change: 0 additions & 1 deletion Tests/Functional/app/ViewResponseListener/config.yml
@@ -1,6 +1,5 @@
imports:
- { resource: ../config/default.yml }
- { resource: ../config/default.php }
- { resource: ../config/sensio_framework_extra.yml }

framework:
Expand Down
7 changes: 0 additions & 7 deletions Tests/Functional/app/config/default.php

This file was deleted.

0 comments on commit a360f26

Please sign in to comment.