I've installed the FOSUserBundle on Symfony 2 for MongoDB and I would like to add some custom fields but they are always empty.
My UserBundle:
<?php
namespace Skurty\UserBundle\Document;
use FOS\UserBundle\Model\User as BaseUser;
use Doctrine\ODM\MongoDB\Mapping\Annotations as MongoDB;
/**
* @MongoDB\Document(
* collection="user"
* )
*/
class User extends BaseUser
{
/**
* @MongoDB\Id(strategy="auto")
*/
protected $id;
/**
* @MongoDB\String
*/
protected $test;
public function setTest($test)
{
$this->test = $test;
}
public function getTest()
{
return $this->test;
}
}
A controller (not in the same bundle that the UserBundle):
$user = $this->getUser();
// or
$user = $this->get('doctrine_mongodb')
->getRepository('SkurtyUserBundle:User')
->find(new \MongoId('...'));
// $user->getUsername() => 'skurty'
// $user->getTest() => null
And the MongoDB document:
{ "_id" : ObjectId("..."), "username" : "skurty", /* FOSUserBundle fields */, "test" : "abc" }
What is wrong?
Thank you