2017-06-21 218 views
1

我重写我的FOS_User实体password领域,这种方式:无效的领域覆盖

* @ORM\AttributeOverrides({ 
    * @ORM\AttributeOverride(name="password", 
    *  [email protected]\Column(
    *  nullable=true 
    * ) 
    * ) 
    * }) 

./app/console doctrine:schema:validate检查罚款:

[Mapping] OK - The mapping files are correct.

[Database] OK - The database schema is in sync with the mapping files.

但是当我运行generate:doctrine:entities命令我收到以下错误:

Invalid field override named 'password' for class 'MyAppBundle\Entity\User'.

我的设置有什么问题?

回答

0

试试这个:

/** 
* User 
* @ORM\Entity 
* @ORM\AttributeOverrides({ 
    * @ORM\AttributeOverride(name="password", 
    *  [email protected]\Column(
    *  nullable=true 
    * ) 
    * ) 
    * }) 
*/ 
class yourUser extends BaseUser 
{ 
    /** 
    * @ORM\password() 
    * @ORM\Column(type="string") 
    */ 
    protected $password; 

    //other code 
} 

一定要使用最新学说的版本,因为覆盖从学说版本支持2.3

+1

@ORM \密码()无法识别:'[语义错误]属性My \ AppBundle \ Entity \ User :: $密码中的注释“@Doctrine \ ORM \ Mapping \ password”不存在,或者无法自动加载。“我使用的是Symfony 2.5,而'password'注释不是可在vendor/doctrine/orm/lib/Doctrine/ORM/Mapping / – anthony