How to install SonataDoctrineMongoDBAdminBundle properly?

走远了吗. 提交于 2019-12-03 03:40:42

Seems that inheritance mapping is not working right, I followed the instructions but it lead to same problem. I got it fixed by changing reference to BaseUser to class provided by FOS\UserBundle

# Application\Sonata\UserBundle\Document\User.php

namespace Application\Sonata\UserBundle\Document;

//use Sonata\UserBundle\Document\BaseUser as BaseUser;
use FOS\UserBundle\Document\User as BaseUser;
AkD3vs

I was also having issues with this, the users were created with just an ID, gender: 'u', createdAt, etc. And with this, I was able to make it work:

# app/config/config.yml
doctrine_mongodb:
    connections:
        default:
            server: mongodb://localhost:27017
            options: {}
    default_database: test
    document_managers:
        default:
            mappings:
                ApplicationSonataUserBundle: ~
                SonataUserBundle: ~
                FOSUserBundle: ~

I hope someone find this useful.

I'm stucked at the same point.

I created user.php in a different folder with a different name, for my organization.

The difference was that I put direcly mongodb annotations

namespace myProject\BackEndBundle\Document;

use FOS\UserBundle\Document\User as BaseUser;
use Doctrine\ODM\MongoDB\Mapping\Annotations as MongoDB;

/**
 * @MongoDB\Document
 */
class BackEndUser extends BaseUser {
    /**
     * @MongoDB\Id
     */
    protected $id;

    /**
     * Get id
     *
     * @return id $id
     */
    public function getId()
    {
        return $this->id;
    }

    public function __construct()
    {
        parent::__construct();
        // your own logic
    }
}

Now user creation and authentication works, but user management in SonataAdminBundle don't works.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!