Skip to content

Commit dda96d4

Browse files
author
Denis Brumann
authored
Make error plugin configurable (#419)
1 parent 4e3b01a commit dda96d4

File tree

5 files changed

+34
-0
lines changed

5 files changed

+34
-0
lines changed

Diff for: CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
The change log describes what is "Added", "Removed", "Changed" or "Fixed" between each release.
44

5+
# 1.27.0 - 2022-07-25
6+
7+
- Added support for configuring the error plugin via configuration
8+
59
# 1.26.2 - 2022-06-01
610

711
- Fixed: You can now configure the cache plugin option `cache_lifetime` to `null` (which makes the plugin not add to the maxAge).

Diff for: src/DependencyInjection/Configuration.php

+9
Original file line numberDiff line numberDiff line change
@@ -590,6 +590,15 @@ private function addSharedPluginNodes(ArrayNodeDefinition $pluginNode, $disableA
590590
->end()
591591
->end();
592592
// End stopwatch plugin
593+
594+
$error = $children->arrayNode('error')
595+
->canBeEnabled()
596+
->addDefaultsIfNotSet()
597+
->children()
598+
->scalarNode('only_server_exception')->defaultFalse()->end()
599+
->end()
600+
->end();
601+
// End error plugin
593602
}
594603

595604
/**

Diff for: src/DependencyInjection/HttplugExtension.php

+7
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,13 @@ private function configurePluginByName($name, Definition $definition, array $con
275275

276276
break;
277277

278+
case 'error':
279+
$definition->addArgument([
280+
'only_server_exception' => $config['only_server_exception'],
281+
]);
282+
283+
break;
284+
278285
/* client specific plugins */
279286

280287
case 'add_host':

Diff for: tests/Unit/DependencyInjection/ConfigurationTest.php

+8
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,10 @@ class ConfigurationTest extends AbstractExtensionConfigurationTestCase
9494
'enabled' => true,
9595
'stopwatch' => 'debug.stopwatch',
9696
],
97+
'error' => [
98+
'enabled' => false,
99+
'only_server_exception' => false,
100+
],
97101
],
98102
'discovery' => [
99103
'client' => 'auto',
@@ -294,6 +298,10 @@ public function testSupportsAllConfigFormats(): void
294298
'enabled' => false,
295299
'stopwatch' => 'debug.stopwatch',
296300
],
301+
'error' => [
302+
'enabled' => false,
303+
'only_server_exception' => false,
304+
],
297305
],
298306
'discovery' => [
299307
'client' => 'auto',

Diff for: tests/Unit/DependencyInjection/HttplugExtensionTest.php

+6
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,11 @@ public function testClientPlugins(): void
139139
'cache_pool' => 'my_cache_pool',
140140
],
141141
],
142+
[
143+
'error' => [
144+
'only_server_exception' => true,
145+
],
146+
],
142147
],
143148
],
144149
],
@@ -156,6 +161,7 @@ public function testClientPlugins(): void
156161
'httplug.client.acme.plugin.query_defaults',
157162
'httplug.client.acme.authentication.my_basic',
158163
'httplug.client.acme.plugin.cache',
164+
'httplug.client.acme.plugin.error',
159165
];
160166
$pluginReferences = array_map(function ($id) {
161167
return new Reference($id);

0 commit comments

Comments
 (0)