Symfony1 使用setSfGuardUser()在模型中保存当前用户
我的应用程序使用了sfGuardUser插件。我的一个表与sf_guard_user表有关系,因此在基本模型中有一个相应的setSfGuardUser()函数。在Actions.class.php中,我试图使用此函数将当前用户设置到对象中(然后保存到数据库中)。Symfony1 使用setSfGuardUser()在模型中保存当前用户,symfony1,symfony-1.4,Symfony1,Symfony 1.4,我的应用程序使用了sfGuardUser插件。我的一个表与sf_guard_user表有关系,因此在基本模型中有一个相应的setSfGuardUser()函数。在Actions.class.php中,我试图使用此函数将当前用户设置到对象中(然后保存到数据库中)。 我的尝试: ->setSfGuardUser($this->getUser()); //called from inside Actions.class.php 这会引发一个错误: Couldn't call Doctr
我的尝试:
->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对象,尽管我不知道如何检查它。任何人都可以提供任何见解吗?
$this->getUser()
返回一个myUser
实例。你需要$this->getUser()->getGuardUser()
顺便说一句,我现在做的是:-->setFGuardUser(条令::getTable('sfGuardUser')->findOneByUsername($this->getUser()->getUsername());这似乎有点不必要