简体   繁体   中英

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM