Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3a8f92f

Browse files
committed
Add to configuration
1 parent c3d15fa commit 3a8f92f

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

src/Symfony/Bundle/TwigBundle/DependencyInjection/Configuration.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,28 @@ public function getConfigTreeBuilder()
3535
$rootNode
3636
->children()
3737
->scalarNode('exception_controller')->defaultValue('twig.controller.exception:showAction')->end()
38+
->arrayNode('http_exception_log_levels')
39+
->info('The override log levels for http exceptions')
40+
->example(array('404' => 'info', '403' => 'notice'))
41+
->prototype('array')
42+
->children()
43+
->scalarNode('http_code')
44+
->validate()
45+
->ifTrue(function ($v) {
46+
return !(is_int($v) && 100 <= $v && $v <= 599);
47+
})
48+
->thenInvalid('"%s" is not a valid http status code')
49+
->end()
50+
->end()
51+
->scalarNode('log_level')
52+
->validate()
53+
->ifNotInArray(array('emergency', 'alert', 'critical', 'error', 'warning', 'notice', 'info', 'debug'))
54+
->thenInvalid('"%s" is not a valid log level')
55+
->end()
56+
->end()
57+
->end()
58+
->end()
59+
->end()
3860
->end()
3961
;
4062

src/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ public function load(array $configs, ContainerBuilder $container)
7878
$config = $this->processConfiguration($configuration, $configs);
7979

8080
$container->setParameter('twig.exception_listener.controller', $config['exception_controller']);
81+
$container->setParameter('twig.exception_listener.http_log_levels', $config['http_exception_log_levels']);
8182

8283
$container->setParameter('twig.form.resources', $config['form_themes']);
8384
$container->setParameter('twig.default_path', $config['default_path']);

src/Symfony/Bundle/TwigBundle/Resources/config/twig.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@
128128
<tag name="monolog.logger" channel="request" />
129129
<argument>%twig.exception_listener.controller%</argument>
130130
<argument type="service" id="logger" on-invalid="null" />
131-
<argument>%framework.http_exception.log_levels%</argument>
131+
<argument>%twig.exception_listener.http_log_levels%</argument>
132132
</service>
133133

134134
<service id="twig.controller.exception" class="Symfony\Bundle\TwigBundle\Controller\ExceptionController" public="true">

0 commit comments

Comments
 (0)