Search code examples
phpsymfonydoctrine-ormfosuserbundlemappedsuperclass

Symfony2: Entity extends MappedSuperClass extends FOSUserBundle User


I created a BaseBundle with a SuperUser MappedSuperClass who extends FOSUserBundle User

use FOS\UserBundle\Model\User as FOSUser;

/*
 * @ORM\MappedSuperclass
 */
class SuperUser extends FOSUser
{
  /**
   * @var string
   * @ORM\Column(name="locale", type="string", nullable=true)
   */
  protected $locale;
}

In my Project I installed my BaseBundle. I created a User entity who extends my SuperUser class.

/*
 * User class
 */
class User extends SuperUser
{
   /**
    * @var string
    */
   private $fullName;
}

The problem is that when I create the table, Doctrine see only FOSUser properties and User properties but not my SuperUser properties. I can see only fullName and FOSUser properties.

My SuperUser class is bypassed..

I noticed that User class is with YAML notation, SuperUser is with PHP Annotation while FOSUser Class is with XML notation. I don't know if this create problems.


Solution

  • From the documentation:

    A bundle can accept only one metadata definition format. For example, it's not possible to mix YAML metadata definitions with annotated PHP entity class definitions.

    Try to add the YML mapping of your MappedSuperClass