Skip to content

Make error plugin configurable #419

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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