-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[VarDumper] Allow to use a light theme out of the box #27261
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Depends on where it's used I guess. When it's in the WDT, I'd prefer to keep it dark, but it doesn't seem possible like this (or am I wrong?). |
@iltar : It'll not be used anywhere in core (appart perhaps if we want to use it for the html output of the Point of this is to expose the light theme if you want to exclusively use it instead of the dark theme for your own html dumper usages and also reference this color scheme directly in it rather than having to search it in the profiler css. |
@@ -61,6 +80,7 @@ public function __construct($output = null, string $charset = null, int $flags = | |||
AbstractDumper::__construct($output, $charset, $flags); | |||
$this->dumpId = 'sf-dump-'.mt_rand(); | |||
$this->displayOptions['fileLinkFormat'] = ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format'); | |||
$this->styles = static::$themes['dark'] ?? self::$themes['dark']; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this will break the CliDumper, which was overriding the styles
property, as you now have the HTML styles overriding the CLI ones here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The HtmlDumper
extends the CliDumper
, not the inverse. So I'm not sure how this could break the CliDumper
? HtmlDumper
was already overriding the CliDumper::$styles
before these changes.
btw, the fact that tests are passing tells me we are missing tests for the color support of the CliDumper |
I love this! Also, we need it. In the profiler, we apply special styles to all |
@@ -23,28 +23,47 @@ class HtmlDumper extends CliDumper | |||
{ | |||
public static $defaultOutput = 'php://output'; | |||
|
|||
protected static $themes = array( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tend to believe a public registerTheme($name, $styles, $extends = 'light')
is more useful then static overriding =/
edit: or declare on CliDumper along with setTheme, enabling the feat. there as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure we want to allow people to register new themes.
I'm wondering: should we move this to another class, following SRP? This is a helper around "setStyles", so could be decoupled. WDYT? |
@nicolas-grekas : Something like a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
with minor comments
public function setTheme(string $themeName) | ||
{ | ||
if (!isset(static::$themes[$themeName])) { | ||
throw new \InvalidArgumentException(sprintf('Theme "%s" does not exist in class "%s"', $themeName, static::class)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing dot at the end of the exception message.
@@ -23,28 +23,47 @@ class HtmlDumper extends CliDumper | |||
{ | |||
public static $defaultOutput = 'php://output'; | |||
|
|||
protected static $themes = array( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure we want to allow people to register new themes.
@ogizanagi Can we finish this one so that we can merge it for 4.2? |
@fabpot : Sure, sorry for the lack of answer. But do we agree to keep |
(Rebased and fixed the exception message) |
Thank you @ogizanagi. |
…(ogizanagi) This PR was merged into the 4.2-dev branch. Discussion ---------- [VarDumper] Allow to use a light theme out of the box | Q | A | ------------- | --- | Branch? | master <!-- see below --> | Bug fix? | no | New feature? | yes <!-- don't forget to update src/**/CHANGELOG.md files --> | BC breaks? | no <!-- see https://symfony.com/bc --> | Deprecations? | no <!-- don't forget to update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Tests pass? | yes <!-- please add some, will be required by reviewers --> | Fixed tickets | N/A <!-- #-prefixed issue number(s), if any --> | License | MIT | Doc PR | N/A Wouldn't it be nice to provide this light theme out of the box? (the one we use in the profiler)  Commits ------- c705b82 [VarDumper] Allow to use a light theme out of the box
…n (derrabus) This PR was merged into the 6.4 branch. Discussion ---------- [DebugBundle] Remove obsolete VarDumper feature detection | Q | A | ------------- | --- | Branch? | 6.4 | Bug fix? | no | New feature? | no | Deprecations? | no | Tickets | N/A | License | MIT | Doc PR | N/A This PR removes detection for features introduced with #30301 (Symfony 4.3) and #27261 (Symfony 4.2). Commits ------- 9f9747c [DebugBundle] Remove obsolete VarDumper feature detection
Wouldn't it be nice to provide this light theme out of the box? (the one we use in the profiler)