Failed to create url for "page_slug" after creating user

I have a strange problem. I installed and configured SonataUserBundle to work with FosUserBundle and SonataAdminBundle. Installed went without a problem, and everything seems to work fine, except when I create another user through the sonataUserBundle web page. As soon as I create a user (and it is created when I look in the database), I no longer see the list of users. When I click to return to the list of users, I get the following error:

An exception has been thrown during the rendering of a template ("Unable to generate a URL for the named route "page_slug" as such route does not exist.") in "SonataAdminBundle:CRUD:list.html.twig".

If I remove a user from the database in order to have only one user, I can access the list of users.

I have absolutely no idea how to solve, how to solve this problem ...

Change 1:

Thanks to Marco Jurincic, I found out that I have these lines in my configuration

sonata_user:

    impersonating:
        route:                page_slug
        parameters:           { path: / }

However, this does not look like a route and is effective; there are no routes named page_slug. Is it supposed to have a route name of "page_slug"?

+4
source share
3 answers

I saw the approach on the website ( http://www.laurent-masforne.com/memo/surcharger-sonatauserbundle-notamment-useradmin/ ) and commenting on these lines:

/*if ($this->isGranted('ROLE_ALLOWED_TO_SWITCH')) {
            $listMapper
                ->add('impersonating', 'string', array('template' => 'SonataUserBundle:Admin:Field/impersonating.html.twig'))
            ;
        }*/

in vendor\sonata-project\user-bundle\Sonata\UserBundle\Admin\Model\ApplicationUserAdmin

solved the problem. However, I do not know the consequences of this behavior ...

+2
source

. , , page_slug , , page_slug config.yml sonata_user

impersonating:
  route: page_slug
  parameters: { path: / }  

, - ( Symfony, 100%, - :))

( ) , -dahsboard.

, .

EDIT: . : https://github.com/sonata-project/SonataUserBundle/issues/174

+5

, config:

impersonating:
  route:                page_slug
  parameters:           { path: / }

(, google wanderers)

:
1. ROLE_ALLOWED_TO_SWITCH. :

# app/config/security.yml  
security:  
  role_hierarchy:  
    ROLE_ADMIN:  [ROLE_USER, ROLE_ALLOWED_TO_SWITCH]

2. :

# app/config/security.yml      
firewalls:
  main:
    switch_user: true

3. ( Sonata Admin) Setup SonataUserBundle - my_home_route , :

# app/config/config.yml
sonata_user:
  impersonating:
    route:  my_home_route

URL: ?_switch_user=username. username .

+5

All Articles