Skip to content

[SecurityBundle] Allow developers to override profiler toolbar #42464

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

Closed

Conversation

odolbeau
Copy link
Contributor

Q A
Branch? 5.4
Bug fix? no
New feature? yes
Deprecations? no
Tickets -
License MIT
Doc PR -

This very simple PR allow the developer to override the security profiler toolbar to add custom information.

Its as simple as creating a template in templates/bundles/SecurityBundle/Collector/security.html.twig containing extra information like this:

{% extends '@!Security/Collector/security.html.twig' %}

{% block additional_toolbar_information %}
    <div class="sf-toolbar-info-group">
        <div class="sf-toolbar-info-piece">
            <b>A custom information</b>
            <span class="sf-toolbar-status sf-toolbar-status-yellow">Foobar</span>
        </div>
    </div>
{% endblock %}

Here is the result you get
image

This can be pretty useful to add extra information directly linked to the connected user when relevant (could be an attribute from the entity, a link to an external profile like Stripe or anything else, ...) without creating a custom data collector nor overwriting the whole parent toolbar block.

  • The same logic could be used for other profiler toolbars if you consider it makes sense
  • We could add 2 blocks, respectively at the beginning & at the end of the existing text variable.

WDYT?

@carsonbot carsonbot added Status: Needs Review DX DX = Developer eXperience (anything that improves the experience of using Symfony) Feature RFC RFC = Request For Comments (proposals about features that you want to be discussed) labels Aug 10, 2021
@carsonbot carsonbot changed the title [RFC][DX] Allow developers to override profiler toolbar Allow developers to override profiler toolbar Aug 10, 2021
@carsonbot carsonbot changed the title Allow developers to override profiler toolbar [SecurityBundle] Allow developers to override profiler toolbar Aug 10, 2021
@carsonbot
Copy link

Hey!

I think @ismail1432 has recently worked with this code. Maybe they can help review this?

Cheers!

Carsonbot

@noniagriconomie
Copy link
Contributor

this will works "only" for static data or dynamic already collected via the related collector right?
is there a way to hook into the related collector logic to inject internal things?

@lyrixx
Copy link
Member

lyrixx commented Aug 11, 2021

@jderusse has opened another issue related to this topic iirc

@nicolas-grekas nicolas-grekas added this to the 5.4 milestone Aug 11, 2021
@jderusse
Copy link
Member

jderusse commented Aug 11, 2021

@jderusse has opened another issue related to this topic iirc

I think your are talking about #39114

We ended that the profiler is not the right place for static data.
But on my to-do list I would like working on spliting the profiler toolbar/dashboard in:

  • request-related data
  • static data (ie. PHP info, router/container debug, ...)

@fabpot
Copy link
Member

fabpot commented Sep 21, 2021

I would recommend implementing a new data collector with your data, which let you control everything in a better way without messing up with the existing tabs.

@fabpot fabpot closed this Sep 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DX DX = Developer eXperience (anything that improves the experience of using Symfony) Feature RFC RFC = Request For Comments (proposals about features that you want to be discussed) SecurityBundle Status: Needs Review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants