Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/svn/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Symfony1 使用setSfGuardUser()在模型中保存当前用户_Symfony1_Symfony 1.4 - Fatal编程技术网

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

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

我的应用程序使用了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对象,尽管我不知道如何检查它。任何人都可以提供任何见解吗?

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

顺便说一句,我现在做的是:-->setFGuardUser(条令::getTable('sfGuardUser')->findOneByUsername($this->getUser()->getUsername());这似乎有点不必要