2013-02-26 1 views
0

내가 Symfony2에서 FosUserBundle 다음과 같은 코드를 실행 작동하지 않습니다. getId()이 작동하지 않는 이유는 무엇입니까? 내 user.php에서GetId는

내 게터는 :

public function getId() 
{ 
    return parent::getId(); 
} 
+0

사용자 등급을 게시 할 수 있습니까? 부모 ID 속성도 무시합니까? –

답변

0

https://github.com/FriendsOfSymfony/FOSUserBundle/blob/master/Resources/doc/index.md에 따르면이 사용자 클래스가 같이하는 방법입니다.

class User extends BaseUser 
{ 
    /** 
    * @ORM\Id 
    * @ORM\Column(type="integer") 
    * @ORM\GeneratedValue(strategy="AUTO") 
    */ 
    protected $id; 

    public function __construct() 
    { 
     parent::__construct(); 
     // your own logic 
    } 
} 

당신은

return $this->id; 

가 작동해야 위의 클래스와

return parent::getId(); 

를 호출 할 필요가 없습니다.