我是Symfony的新手,實際上我正嘗試從我的user.php模板中使用我自己的方法。它看起來像這樣:FOSUserBundle使用自己的方法
{% for image in app.user.getUserImage %}
...
,但我得到的唯一的事情是:
An exception has been thrown during the rendering of a template ("Notice: Undefined
index: User
...
到現在我認爲我的user.php的(我的方法包含)擴展到FOSUserBundle因此它可以在模板中使用。
因爲這個原因,我必須重寫FOSUserBundle控制器嗎?
@MDrollette:
從user.php的:
/**
* Get userimage
*
* @return Doctrine\Common\Collections\Collection
*/
public function getUserimage()
{
return $this->userimage;
}
/**
* @ORM\OneToMany(targetEntity="UserImage", mappedBy="User")
* @var ArrayCollection $userimage
*/
protected $userimage;
我覺得這裏正在做其他事情。這並不是說它找不到getUserImage方法,而是給出了一個不同的錯誤。在這裏可能需要更多的信息來調試,你可以發佈'getUserImage()'的內容嗎? – MDrollette
請看看我的編輯 –