Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 91e8057

Browse filesBrowse files
dem3triofabpot
authored andcommitted
[DebugBundle] Added 'theme' option to change the color of dump() when rendered inside templates
1 parent 10b3d00 commit 91e8057
Copy full SHA for 91e8057

File tree

Expand file treeCollapse file tree

2 files changed

+22
-2
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+22
-2
lines changed

‎src/Symfony/Bundle/DebugBundle/DependencyInjection/Configuration.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/DebugBundle/DependencyInjection/Configuration.php
+16-2Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
1515
use Symfony\Component\Config\Definition\ConfigurationInterface;
16+
use Symfony\Component\VarDumper\Dumper\HtmlDumper;
1617

1718
/**
1819
* DebugExtension configuration structure.
@@ -28,8 +29,8 @@ public function getConfigTreeBuilder()
2829
{
2930
$treeBuilder = new TreeBuilder('debug');
3031

31-
$treeBuilder->getRootNode()
32-
->children()
32+
$rootNode = $treeBuilder->getRootNode();
33+
$rootNode->children()
3334
->integerNode('max_items')
3435
->info('Max number of displayed items past the first level, -1 means no limit')
3536
->min(-1)
@@ -53,6 +54,19 @@ public function getConfigTreeBuilder()
5354
->end()
5455
;
5556

57+
if (method_exists(HtmlDumper::class, 'setTheme')) {
58+
$rootNode
59+
->children()
60+
->enumNode('theme')
61+
->info('Changes the color of the dump() output when rendered directly on the templating. "dark" (default) or "light"')
62+
->example('dark')
63+
->values(array('dark', 'light'))
64+
->defaultValue('dark')
65+
->end()
66+
->end()
67+
;
68+
}
69+
5670
return $treeBuilder;
5771
}
5872
}

‎src/Symfony/Bundle/DebugBundle/DependencyInjection/DebugExtension.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/DebugBundle/DependencyInjection/DebugExtension.php
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
1919
use Symfony\Component\DependencyInjection\Reference;
2020
use Symfony\Component\VarDumper\Dumper\CliDumper;
21+
use Symfony\Component\VarDumper\Dumper\HtmlDumper;
2122

2223
/**
2324
* DebugExtension.
@@ -42,6 +43,11 @@ public function load(array $configs, ContainerBuilder $container)
4243
->addMethodCall('setMinDepth', array($config['min_depth']))
4344
->addMethodCall('setMaxString', array($config['max_string_length']));
4445

46+
if (method_exists(HtmlDumper::class, 'setTheme') && 'dark' !== $config['theme']) {
47+
$container->getDefinition('var_dumper.html_dumper')
48+
->addMethodCall('setTheme', array($config['theme']));
49+
}
50+
4551
if (null === $config['dump_destination']) {
4652
$container->getDefinition('var_dumper.command.server_dump')
4753
->setClass(ServerDumpPlaceholderCommand::class)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.