Closed rbs-asimon closed 4 years ago
I filter the sonata_user_security_*
and sonata_user_registration_*
in the sonata_page.yml
as workaround. You end up with only FOS routes. However the Sonata functionality stays intact.
sonata_page:
ignore_route_patterns:
...
- ^sonata_user_security(.*) # Ignore sonata user routes
- ^sonata_user_registration(.*) # Ignore sonata user routes
...
@Neodork the code modification does not care about FOS or not FOS. In fact the first (ordered by $router->getRouteCollection()->all() ) route declaration wins. And if I remember well, that is the way the Symfony router handle things.
@core23 I'm sorry I really had no time to add unit testing or what else. I needed this bundle to work for my company project and, for now, this project takes me too much time to be "gentle".
@rbs-asimon Yes so if I assume it's ordered alphabetically ordered by the order of routes getting loaded, sonata routes will always be second compared to the FOS ones. So ignoring the sonata routes will get rid of the duplicate routes in the CMS and keep functionality. It is however prone to break and I think your PR would be ideal to fix the problem once and for all.
Like I mentioned it's only a workaround.
I do not recommend using sonata_user routes instead of fos_user for your custom login page, since I am trying to remove a lot of duplicated code between FOSUser and Sonata.
Look at this PR: https://github.com/sonata-project/SonataUserBundle/pull/869
Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
Environment
Sonata packages
Symfony packages
PHP version
Subject
When you install SonataUserBundle and use Sonata Controllers instead of FOS one, (Cf. https://github.com/sonata-project/SonataUserBundle/blob/3.x/Resources/doc/reference/installation.rst#use-custom-sonatauser-controllers-and-templates-instead-of-fosuser-ones), you get multiple pages sharing the same path like the screenshot of the official Sonata demo shows :
It should not be a problem except it breaks totally the possibility to edit one of these pages (
BasePage.routeName
property is unique).My understanding is that the sonata_* routes are only required to do some clean separation for a project using these routes or not. So it is possible to ignore the routes during the page creation process (
./bin/console sonata:page:update-core-routes
)Steps to reproduce
Install SonataUserBundle and activate Sonata Controllers like described here : https://github.com/sonata-project/SonataUserBundle/blob/3.x/Resources/doc/reference/installation.rst#use-custom-sonatauser-controllers-and-templates-instead-of-fosuser-ones
See the multiple duplicates in admin :
Try to edit one of these pages and cry because it is not possible (crying is optional ;) ).
Expected results
Sonata\PageBundle\Route\RoutePageGenerator
should ignore the routes that are already defined (the Symfony router retains the first one).fos_*
routes likefos_user_security_login
orfos_user_change_password
should be editableActual results