Symfony2类UserInterface不存在

时间:2012-12-14 11:42:16

标签: symfony user-interface

我正在使用Symfony 2.1建立一个客户案例管理系统,我偶然发现了这个我无法解决的奇怪问题。由于某些原因,当我使用CustomerCaseController执行showAction时,出现以下错误:

  

"类HSW \ AshaBundle \ Entity \ UserInterface不存在"
  500内部服务器错误

我不知道应用程序的哪个部分需要该接口。 如果我创建一个空的UserInterface.php类,问题就会消失,一切正常。为什么showAction需要UserInterface

我已经缩小了问题,以某种方式与showController中的这段代码相关:

$customercase = $this->getDoctrine() ->getRepository('HSWAshaBundle:CustomerCase') ->find($id);

我有以下实体:

  • User(用于登录和提交案例)
  • Customer(针对客户)
  • CustomerCase(适用于个案)。

CustomerCase通过以下方式与CustomerUser个实体建立了ManyToOne关系:

// src / HSW / AshaBundle / Entity / CustomerCase.php     名称空间HSW \ AshaBundle \ Entity;

use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use Doctrine\Common\Collections\ArrayCollection;

/**
 * CustomerCase
 *
 * @ORM\Table(name="hsw_customerCase")
 * @ORM\Entity
 * @Gedmo\Loggable
 * @Gedmo\SoftDeleteable(fieldName="deletedAt")
 */
class CustomerCase
{

/** 
 * @ORM\ManyToOne(targetEntity="Customer", inversedBy="customerCases") 
 * @ORM\JoinColumn(name="customer_id", referencedColumnName="id", nullable=false) 
 */
protected $customer;

/** 
 * @ORM\ManyToOne(targetEntity="User", inversedBy="createdCustomerCases") 
 * @ORM\JoinColumn(name="creator_id", referencedColumnName="id", nullable=false) 
 */
protected $creator;

/** 
 * @ORM\ManyToOne(targetEntity="User", inversedBy="holdingCustomerCases") 
 * @ORM\JoinColumn(name="holder_id", referencedColumnName="id", nullable=false) 
 */
protected $holder;
.....etc....

// src / HSW / AshaBundle / Entity / CustomerCase.php     名称空间HSW \ AshaBundle \ Entity;

use Symfony\Component\Security\Core\User\EquatableInterface;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Security\Core\User\AdvancedUserInterface;
use Doctrine\Common\Collections\ArrayCollection;

/**
 * HSW\AshaBundle\Entity\User
 *
 * @ORM\Table(name="hsw_users")
 * @ORM\Entity(repositoryClass="HSW\AshaBundle\Entity\UserRepository")
 */

class User implements AdvancedUserInterface
{
.....etc....

与用户实体的关系能否以某种方式影响这一点?这是我在CustomerCase.phpCustomer.php之间看到的唯一可见区别(其中showAction }没有UserInterface)。

有人可以帮我调试这种行为吗?仅仅因为Symfony需要(因为未知原因)而拥有一个空的UserInterface类似乎没用。

1 个答案:

答案 0 :(得分:0)

我猜你没有将UserInterface的命名空间导入你的用户类(我猜它是一个User类,因为你没有提到它):

use Symfony\Component\Security\Core\User\UserInterface;

class User implements UserInterface
{
}

继续阅读PHP namespaces in the official docs