Inheritance Symfony2/FOS调用用户模型上的未定义方法
这是我在(例如)转到注册url时收到的错误消息:Inheritance Symfony2/FOS调用用户模型上的未定义方法,inheritance,symfony,fosuserbundle,Inheritance,Symfony,Fosuserbundle,这是我在(例如)转到注册url时收到的错误消息: **Call to undefined method MyEntity::setEnabled() FOS\UserBundle\Controller\RegistrationController.php on line 44** (FOS已在我的内核中注册) 我自己的用户实体扩展了FOS\UserBundle\Model\user,我也尝试了扩展FOS\UserBundle\entity\user 因此: <?php namespac
**Call to undefined method MyEntity::setEnabled() FOS\UserBundle\Controller\RegistrationController.php on line 44**
(FOS已在我的内核中注册)
我自己的用户实体扩展了FOS\UserBundle\Model\user,我也尝试了扩展FOS\UserBundle\entity\user
因此:
<?php
namespace NRtworks\SubscriptionBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
use FOS\UserBundle\Model\User as BaseUser;
/**
* @ORM\Entity
* @ORM\Table(name="icousers")
*/
class icousers extends BaseUser
{
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @ORM\Column(type="string", length=50, unique = true)
*/
protected $type;
/**
* @ORM\Column(type="integer", length=5)
*/
protected $customer;
public function __construct()
{
parent::__construct();
// your own logic
}
public function getid()
{
return $this->id;
}
public function gettype()
{
return $this->type;
}
public function getcustomer()
{
return $this->customer;
}
public function setid($x)
{
return $this->id=$x;
}
public function settype($x)
{
return $this->type=$x;
}
public function setcustomer($x)
{
return $this->customer=$x;
}
}
?>
我没有更改代码,因此setEnabled方法被写入FOS\UserBundle\Model\User
我不知道这里怎么了
我使用Symfony 2.1.7您的ICO用户必须扩展UserBundle\Entity\User。按照自述文件中的说明操作。不确定错误消息来自何处。首先验证从$userManager->getUser返回的$user类。我很确定这不会是icousers的例子。谢谢你的回答。我发现了我的错误,这是一个愚蠢的错误(与捆绑技术无关)。