SonataUserBundle's admin lists/inserts to fos_user_user and not my user table

976 views Asked by At

I 'm using FOSUserBundle + SonataUserBundle in Symfony2.
I extended Sonata's BaseUser like this:

namespace ar1y4n\UserBundle\Entity;

use Sonata\UserBundle\Entity\BaseUser as BaseUser;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;

/**
 * @ORM\Entity
 * @ORM\Table(name="users")
 */
class User extends BaseUser{
[...]

and my config.yml is:

fos_user:
    db_driver: orm 
    firewall_name: main
    user_class:     ar1y4n\UserBundle\Entity\User
    group:
        group_class: ar1y4n\UserBundle\Entity\Group  

sonata_user:
    security_acl: true
    class:                  # Entity Classes
        user:               ar1y4n\UserBundle\Entity\User
        group:              ar1y4n\UserBundle\Entity\Group  

it logins into /admin area uing users in users table; But when viewing users list in admin it shows none of users in users table;
When I create new user using Add User in admin page it adds user to fos_user_user table instead of users table.
it also created fos_user_user & fos_user_group.

What is the problem?
How can I change working table of SonataUserBundle?

Thanks

1

There are 1 answers

0
Ariyan On BEST ANSWER

Found the problem:
When I extend the Sonata\UserBundle\Entity\BaseUser & Sonata\UserBundle\Entity\BaseGroup I should not generate userbundle in Application namespace using app/console sonata:easy-extends:generate SonataUserBundle --dest=src so new Application\Sonata\UserBundle\ApplicationSonataUserBundle(), shouldn't be loaded in AppKernel.php.
Instead in parameters.yml I should add these:

sonata.user.admin.user.entity: ar1y4n\UserBundle\Entity\User
sonata.user.admin.group.entity: ar1y4n\UserBundle\Entity\Group

Now it works with users table as ar1y4n\UserBundle\Entity\User entity uses it.