使用setSfGuardUser()将当前用户保存在模型中

时间:2010-05-19 23:17:12

标签: symfony1 symfony-1.4

我的应用程序使用了sfGuardUser插件。我的一个表与sf_guard_user表有关系,因此在基本模型中有相应的setSfGuardUser()函数。从Actions.class.php,我试图使用此函数将当前用户设置为对象(然后我将其保存在数据库中)。
我的尝试:

->setSfGuardUser($this->getUser());  //called from inside Actions.class.php

这会引发错误:

Couldn't call Doctrine_Core::set(), second argument should be an instance of Doctrine_Record or Doctrine_Null when setting one-to-one references.

...# at Doctrine_Record->coreSetRelated('sfGuardUser', object('myUser'))

这让我觉得getUser()没有返回sfGuardUser对象,虽然我不知道如何检查它。任何人都可以提供任何见解吗?

1 个答案:

答案 0 :(得分:2)

$this->getUser()会返回myUser个实例。您需要$this->getUser()->getGuardUser()

相关问题