Skip to content

Commit

Permalink
Make error plugin configurable (#419)
Browse files Browse the repository at this point in the history
  • Loading branch information
Denis Brumann authored Jul 25, 2022
1 parent 4e3b01a commit dda96d4
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
9 changes: 9 additions & 0 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

/**
Expand Down
7 changes: 7 additions & 0 deletions src/DependencyInjection/HttplugExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -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':
Expand Down
8 changes: 8 additions & 0 deletions tests/Unit/DependencyInjection/ConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ class ConfigurationTest extends AbstractExtensionConfigurationTestCase
'enabled' => true,
'stopwatch' => 'debug.stopwatch',
],
'error' => [
'enabled' => false,
'only_server_exception' => false,
],
],
'discovery' => [
'client' => 'auto',
Expand Down Expand Up @@ -294,6 +298,10 @@ public function testSupportsAllConfigFormats(): void
'enabled' => false,
'stopwatch' => 'debug.stopwatch',
],
'error' => [
'enabled' => false,
'only_server_exception' => false,
],
],
'discovery' => [
'client' => 'auto',
Expand Down
6 changes: 6 additions & 0 deletions tests/Unit/DependencyInjection/HttplugExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,11 @@ public function testClientPlugins(): void
'cache_pool' => 'my_cache_pool',
],
],
[
'error' => [
'only_server_exception' => true,
],
],
],
],
],
Expand All @@ -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);
Expand Down

0 comments on commit dda96d4

Please sign in to comment.