diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php index 6fa53ed4..36e8d007 100644 --- a/src/DependencyInjection/Configuration.php +++ b/src/DependencyInjection/Configuration.php @@ -518,9 +518,15 @@ public function getConfigTreeBuilder(): TreeBuilder ->prototype('scalar')->end() ->end() ->arrayNode('excluded_http_codes') // fingers_crossed + ->info('Only for "fingers_crossed" handler type') + ->example([403, 404, [400 => ['^/foo', '^/bar']]]) ->canBeUnset() ->beforeNormalization() ->always(function ($values) { + if (false === $values) { + return false; + } + return array_map(function ($value) { /* * Allows YAML: diff --git a/tests/DependencyInjection/ConfigurationTest.php b/tests/DependencyInjection/ConfigurationTest.php index 27ad24da..e665290f 100644 --- a/tests/DependencyInjection/ConfigurationTest.php +++ b/tests/DependencyInjection/ConfigurationTest.php @@ -74,6 +74,43 @@ public function testProcessStringChannels($string, $expectedString, $isInclusive $this->assertEquals($expectedString, $config['handlers']['foobar']['channels']['elements'][0]); } + public function testUnsetExcludedHttpCodes() + { + $configs = [ + [ + 'handlers' => [ + 'main' => [ + 'type' => 'fingers_crossed', + 'action_level' => 'error', + 'handler' => 'nested', + 'excluded_http_codes' => [404, 405], + 'channels' => ['!event'], + ], + 'nested' => [ + 'type' => 'stream', + 'path' => '%kernel.logs_dir%/%kernel.environment%.log', + 'level' => 'debug', + ], + ], + ], + [ + 'handlers' => [ + 'main' => [ + 'type' => 'stream', + 'path' => '%kernel.logs_dir%/%kernel.environment%.log', + 'level' => 'debug', + 'excluded_http_codes' => false, + ], + ], + ], + ]; + + $config = $this->process($configs); + + $this->assertArrayNotHasKey('excluded_http_codes', $config['handlers']['main']); + $this->assertIsArray($config['handlers']['main']['channels']); + } + public static function provideGelfPublisher(): array { return [