diff --git a/CHANGELOG.md b/CHANGELOG.md index f52fcc21..871b3409 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ The change log describes what is "Added", "Removed", "Changed" or "Fixed" between each release. +# 1.27.0 - 2022-07-25 + +- Added support for configuring the error plugin via configuration + # 1.26.2 - 2022-06-01 - Fixed: You can now configure the cache plugin option `cache_lifetime` to `null` (which makes the plugin not add to the maxAge). diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php index 2d7b7e5e..74c612a6 100644 --- a/src/DependencyInjection/Configuration.php +++ b/src/DependencyInjection/Configuration.php @@ -590,6 +590,15 @@ private function addSharedPluginNodes(ArrayNodeDefinition $pluginNode, $disableA ->end() ->end(); // End stopwatch plugin + + $error = $children->arrayNode('error') + ->canBeEnabled() + ->addDefaultsIfNotSet() + ->children() + ->scalarNode('only_server_exception')->defaultFalse()->end() + ->end() + ->end(); + // End error plugin } /** diff --git a/src/DependencyInjection/HttplugExtension.php b/src/DependencyInjection/HttplugExtension.php index 22912197..38a042aa 100644 --- a/src/DependencyInjection/HttplugExtension.php +++ b/src/DependencyInjection/HttplugExtension.php @@ -275,6 +275,13 @@ private function configurePluginByName($name, Definition $definition, array $con break; + case 'error': + $definition->addArgument([ + 'only_server_exception' => $config['only_server_exception'], + ]); + + break; + /* client specific plugins */ case 'add_host': diff --git a/tests/Unit/DependencyInjection/ConfigurationTest.php b/tests/Unit/DependencyInjection/ConfigurationTest.php index 74cbf16b..c05a9bd0 100644 --- a/tests/Unit/DependencyInjection/ConfigurationTest.php +++ b/tests/Unit/DependencyInjection/ConfigurationTest.php @@ -94,6 +94,10 @@ class ConfigurationTest extends AbstractExtensionConfigurationTestCase 'enabled' => true, 'stopwatch' => 'debug.stopwatch', ], + 'error' => [ + 'enabled' => false, + 'only_server_exception' => false, + ], ], 'discovery' => [ 'client' => 'auto', @@ -294,6 +298,10 @@ public function testSupportsAllConfigFormats(): void 'enabled' => false, 'stopwatch' => 'debug.stopwatch', ], + 'error' => [ + 'enabled' => false, + 'only_server_exception' => false, + ], ], 'discovery' => [ 'client' => 'auto', diff --git a/tests/Unit/DependencyInjection/HttplugExtensionTest.php b/tests/Unit/DependencyInjection/HttplugExtensionTest.php index e65e977b..405f2bdc 100644 --- a/tests/Unit/DependencyInjection/HttplugExtensionTest.php +++ b/tests/Unit/DependencyInjection/HttplugExtensionTest.php @@ -139,6 +139,11 @@ public function testClientPlugins(): void 'cache_pool' => 'my_cache_pool', ], ], + [ + 'error' => [ + 'only_server_exception' => true, + ], + ], ], ], ], @@ -156,6 +161,7 @@ public function testClientPlugins(): void 'httplug.client.acme.plugin.query_defaults', 'httplug.client.acme.authentication.my_basic', 'httplug.client.acme.plugin.cache', + 'httplug.client.acme.plugin.error', ]; $pluginReferences = array_map(function ($id) { return new Reference($id);