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

Skip to content

[Profiler] make it possible to omit the link var #17402

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

Merged
merged 1 commit into from
Jan 25, 2016

Conversation

xabbuh
Copy link
Member

@xabbuh xabbuh commented Jan 16, 2016

Q A
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets
License MIT
Doc PR

Currently, when you do not want to have a section in the web profiler,
you would have to explicitly pass false as value for the link
variable. With this change you can omit it when including the toolbar
item template.

Currently, when you do not want to have a section in the web profiler,
you would have to explicitly pass `false` as value for the `link`
variable. With this change you can omit it when including the toolbar
item template.
@xabbuh xabbuh force-pushed the profiler-link-optional branch from 7ff7ce7 to c430a47 Compare January 16, 2016 15:38
@@ -1,6 +1,6 @@
<div class="sf-toolbar-block sf-toolbar-block-{{ name }} sf-toolbar-status-{{ status|default('normal') }} {{ additional_classes|default('') }}">
{% if link %}<a href="{{ path('_profiler', { token: token, panel: name }) }}">{% endif %}
{% if link is defined and link %}<a href="{{ path('_profiler', { token: token, panel: name }) }}">{% endif %}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we use {% if link|default(false) %} instead?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could, do you think that's more readable?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if this happens to others, but when I read this code: if link is defined and link it looks to me like something is missing (try to read it as a regular English phrase ... it ends abruptly and it's weird; it should be if link is defined and link is true).

But never mind about my comment ... let's keep your original code.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's see what the other @symfony/deciders think. I am happy to change the code if they agree with you.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xabbuh what do you think about rename link by show_link? link looks as though a URL is required to access of the profile panel IMO.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@weaverryan
Copy link
Member

@xabbuh what was the purpose of this PR? It just seems to make the code less readable. Forcing a boolean link variable that means "do you want a link" (as it is now) makes sense to me.

@xabbuh
Copy link
Member Author

xabbuh commented Jan 16, 2016

@weaverryan I thought about that when removing a hint in the docs which said that the default value was true (so it looks like there was some kind of expectation about desired behaviour). So this change would make it a bit easier for developers using the template (in case we think that showing something in the panel would be an opt-in feature as beside setting link to true you would also have to provide some more markup).

@weaverryan
Copy link
Member

@xabbuh I understand. How does the current link value default to true? I don't see it in the code - I just see how you include this toolbar_item.html.twig template manually (like is shown in the docs): http://symfony.com/doc/current/cookbook/profiler/data_collector.html#adding-web-profiler-templates

Currently, it looks like you must pass link (else you'd get an undefined variable error). Am I wrong?

@yceruto
Copy link
Member

yceruto commented Jan 18, 2016

There is any way to check if menu and panel blocks are defined in the collector template? if possible, this could remove the link parameter and everything would be easier.

@xabbuh
Copy link
Member Author

xabbuh commented Jan 18, 2016

@weaverryan It does not (that's why the description was wrong). And this change just makes it possible that you only have to pass the variable at all if you want to have the profiler link included.

@fabpot
Copy link
Member

fabpot commented Jan 25, 2016

Thank you @xabbuh.

@fabpot fabpot merged commit c430a47 into symfony:master Jan 25, 2016
fabpot added a commit that referenced this pull request Jan 25, 2016
This PR was merged into the 3.1-dev branch.

Discussion
----------

[Profiler] make it possible to omit the link var

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets |
| License       | MIT
| Doc PR        |

Currently, when you do not want to have a section in the web profiler,
you would have to explicitly pass `false` as value for the `link`
variable. With this change you can omit it when including the toolbar
item template.

Commits
-------

c430a47 [Profiler] make it possible to omit the link var
@xabbuh xabbuh deleted the profiler-link-optional branch January 25, 2016 08:19
@fabpot fabpot mentioned this pull request May 13, 2016
ostrolucky pushed a commit to ostrolucky/symfony that referenced this pull request Mar 25, 2018
…r (xabbuh)

This PR was merged into the 3.1-dev branch.

Discussion
----------

[Profiler] make it possible to omit the link var

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets |
| License       | MIT
| Doc PR        |

Currently, when you do not want to have a section in the web profiler,
you would have to explicitly pass `false` as value for the `link`
variable. With this change you can omit it when including the toolbar
item template.

Commits
-------

c430a47 [Profiler] make it possible to omit the link var
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants