2017-06-21 82 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