Permalink
Browse files

feature #29528 [DebugBundle] Added 'theme' option to change the color…

… of dump() when rendered inside templates (dem3trio)

This PR was squashed before being merged into the 4.3-dev branch (closes #29528).

Discussion
----------

[DebugBundle] Added 'theme' option to change the color of dump() when rendered inside templates

| Q             | A
| ------------- | ---
| Branch?       | master for features
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| License       | MIT

Added a html_dumper_theme option config to use the new HtmlDumper light theme when using dump() inside templates

#SymfonyConHackday2018

Commits
-------

91e8057 [DebugBundle] Added 'theme' option to change the color of dump() when rendered inside templates
  • Loading branch information...
fabpot committed Jan 3, 2019
2 parents 10b3d00 + 91e8057 commit 9634a8fd753894a589f62cebc7f6ab85315f78e5
@@ -13,6 +13,7 @@
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;
use Symfony\Component\VarDumper\Dumper\HtmlDumper;
/**
* DebugExtension configuration structure.
@@ -28,8 +29,8 @@ public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder('debug');
$treeBuilder->getRootNode()
->children()
$rootNode = $treeBuilder->getRootNode();
$rootNode->children()
->integerNode('max_items')
->info('Max number of displayed items past the first level, -1 means no limit')
->min(-1)
@@ -53,6 +54,19 @@ public function getConfigTreeBuilder()
->end()
;
if (method_exists(HtmlDumper::class, 'setTheme')) {
$rootNode
->children()
->enumNode('theme')
->info('Changes the color of the dump() output when rendered directly on the templating. "dark" (default) or "light"')
->example('dark')
->values(array('dark', 'light'))
->defaultValue('dark')
->end()
->end()
;
}
return $treeBuilder;
}
}
@@ -18,6 +18,7 @@
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\VarDumper\Dumper\CliDumper;
use Symfony\Component\VarDumper\Dumper\HtmlDumper;
/**
* DebugExtension.
@@ -42,6 +43,11 @@ public function load(array $configs, ContainerBuilder $container)
->addMethodCall('setMinDepth', array($config['min_depth']))
->addMethodCall('setMaxString', array($config['max_string_length']));
if (method_exists(HtmlDumper::class, 'setTheme') && 'dark' !== $config['theme']) {
$container->getDefinition('var_dumper.html_dumper')
->addMethodCall('setTheme', array($config['theme']));
}
if (null === $config['dump_destination']) {
$container->getDefinition('var_dumper.command.server_dump')
->setClass(ServerDumpPlaceholderCommand::class)

0 comments on commit 9634a8f

Please sign in to comment.