sonata-project / SonataAdminBundle

The missing Symfony Admin Generator
https://docs.sonata-project.org/projects/SonataAdminBundle
MIT License
2.11k stars 1.26k forks source link

Absolute admin routes in menu #4175

Closed fracsi closed 6 years ago

fracsi commented 8 years ago

Is there a specific reason why the generated routes in the sidemenu are absolute?

In the Configuration.php the route_absolute: true is hardcoded when using admin ids as items, thus cannot be changed.

OskarStark commented 8 years ago

@rande can you help?

greg0ire commented 8 years ago

@fracsi what does the git log say about this?

fracsi commented 8 years ago

@greg0ire Not much. I only found this PR: #3578

OskarStark commented 8 years ago

@fracsi what is you exact problem?

fracsi commented 8 years ago

@OskarStark It is just a question. Why is it needed? Or if it is needed, then why it cannot be configured?

OskarStark commented 8 years ago

always +1 for configuration, would you provide a PR?

greg0ire commented 8 years ago

Not sure it isn't configurable. The PR you linked to says it is a default value. The variable this goes into is named groupDefaults

fracsi commented 8 years ago

@OskarStark I think it needs more conversation about how it should be done.

Currently:

  1. route_absolute can be configured if using a direct configuration for menu item (not admin), by providing label, route
  2. route_absolute is always true if admin is used, only providing admin service id.
  3. If both admin and route is defined, admin is ignored. (Configuration.php)

I don't know what should be the best to make it configurable.

fracsi commented 8 years ago

@greg0ire If you check the usage of groupDefaults, it is passed to the Pool (setAdminGroups), and that is it. The only solution to modify it would be to get the adminGroups from Pool, modify them and reset them.

fracsi commented 8 years ago

@OskarStark @greg0ire One quick solution would be to remove $items[$key]['admin'] = ''; line from Configuration.php, this way we can configure the menu item as array with an admin id. E.g.:

sonata_admin:
    dashboard:
        groups:
            test_group:
                items:
                    - { admin: my.admin.service.id, route_absolute: false }

Any thougths?

greg0ire commented 8 years ago

@amine2z , can you help? Also, can you link your ekino.com email address to your github account?

rande commented 8 years ago

I don't see the need of an absolute url... but I don't see the issue with absolute url too. If the url is not correct, it just mean the RequestContext is wrong, and should be correctly set either by settings the correct http headers in your RP or by changing the value at the php level.

fracsi commented 8 years ago

@rande There is no issue. I just ran across this "feature"/"bug" and found an inconsistency. Because there is a configuration option, but it cannot be configured if using admin service ids. That is it.

amine2z commented 8 years ago

as @rande said i dont see what is wrong with this. For the moment route_absolute is not used for admin menu items https://github.com/sonata-project/SonataAdminBundle/blob/3.x/Menu/Provider/GroupMenuProvider.php#L129. @greg0ire i don't see why im pinged too, and why you talk about email adresse 😆

greg0ire commented 8 years ago

@amine2z : I pinged you because you're the main author of this piece of code, and I had a hard time finding you because you did not link the email address you make your commits with with your github account (and thus, your username).

fracsi commented 8 years ago

@amine2z As you can see route_absolute is used for admin: https://github.com/sonata-project/SonataAdminBundle/blob/3.x/Menu/Provider/GroupMenuProvider.php#L110

ebuildy commented 7 years ago

Hello, as a conclusion, how can I disable this for all groups? thanks you