I use FOS UserBundle with Sonata Admin/UserBundle, and I wan't to display FOSUserBundle user profile information.
I can access to the localhost/MyWebSite/web/app_dev.php/profile/edit, but I cannot access to localhost/MyWebSite/web/app_dev.php/profile
I have this error :
An exception has been thrown during the rendering of a template ("Unable to generate a URL for the named route "sonata_user_profile_edit" as such route does not exist.") in SonataUserBundle:Profile:action.html.twig at line 27.
I don't understand why an Sonata user profile route was generate when I'm asking for FOSUserBundle profile page
In log file I can see the good rooting message :
INFO - Matched route "fos_user_profile_show".
Thank's for your help.
My routting file
#FOS USER AND SONATA ADMIN ROUTES
fos_user_security:
resource: "@FOSUserBundle/Resources/config/routing/security.xml"
fos_user_profile:
resource: "@FOSUserBundle/Resources/config/routing/profile.xml"
prefix: /profile
fos_user_register:
resource: "@FOSUserBundle/Resources/config/routing/registration.xml"
prefix: /register
fos_user_resetting:
resource: "@FOSUserBundle/Resources/config/routing/resetting.xml"
prefix: /resetting
fos_user_change_password:
resource: "@FOSUserBundle/Resources/config/routing/change_password.xml"
prefix: /change-password
admin:
resource: '@SonataAdminBundle/Resources/config/routing/sonata_admin.xml'
prefix: /admin
_sonata_admin:
resource: .
type: sonata_admin
prefix: /admin
soanata_user:
resource: '@SonataUserBundle/Resources/config/routing/admin_security.xml'
prefix: /admin
sonata_user_impersonating:
pattern: /
defaults: { _controller: SonataPageBundle:Page:catchAll }
homepage:
pattern: /
Edit 1 : I try some debug verification
When I call Url : localhost/MyWebSite/web/app_dev.php/profile the good route fos_user_profile_show was find.
Go in the FOS controller
..\vendor\friendsofsymfony\user-bundle\ FOS \ UserBundle\Controller\ ProfileController.php
But after ProfileController showAction() function, there is a call to **Sonata UserBundle action.html.twig **
Path : ...\vendor\sonata-project\user-bundle\Resources\views\Profile\action.html.twig
I don't understand where is my mistake and how it's possible :-( ...\vendor\friendsofsymfony\user-bundle\FOS\UserBundle\Resources\config\routing\profile.xml
<!--\vendor\friendsofsymfony\user-bundle\FOS\UserBundle\Resources\config\routing\profile.xml-->
<?xml version="1.0" encoding="UTF-8" ?>
<route id="fos_user_profile_show" path="/" methods="GET">
<default key="_controller">FOSUserBundle:Profile:show</default>
</route>
<route id="fos_user_profile_edit" path="/edit" methods="GET POST">
<default key="_controller">FOSUserBundle:Profile:edit</default>
</route>
...\vendor\sonata-project\user-bundle\Resources\config\routing\sonata_profile_1.xml
<routes xmlns="http://symfony.com/schema/routing"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd">
<route id="fos_user_profile_show" pattern="/">
<default key="_controller">SonataUserBundle:ProfileFOSUser1:show</default>
<requirement key="_method">GET</requirement>
</route>
<route id="fos_user_profile_edit_authentication" pattern="/edit-authentication">
<default key="_controller">SonataUserBundle:ProfileFOSUser1:editAuthentication</default>
</route>
<route id="fos_user_profile_edit" pattern="/edit-profile">
<default key="_controller">SonataUserBundle:ProfileFOSUser1:editProfile</default>
</route>
<route id="sonata_user_profile_show" pattern="/">
<default key="_controller">SonataUserBundle:ProfileFOSUser1:show</default>
<requirement key="_method">GET</requirement>
</route>
<route id="sonata_user_profile_edit_authentication" pattern="/edit-authentication">
<default key="_controller">SonataUserBundle:ProfileFOSUser1:editAuthentication</default>
</route>
<route id="sonata_user_profile_edit" pattern="/edit-profile">
<default key="_controller">SonataUserBundle:ProfileFOSUser1:editProfile</default>
</route>