[英]Symfony2 Class UserInterface does not exist
我正在使用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
通過以下方式與Customer
和User
實體建立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....
與User實體的關系能否以某種方式影響這個? 這是我在CustomerCase.php
和Customer.php
之間看到的唯一可見差異( showAction
在沒有UserInterface
情況下工作)。
有人可以幫我調試這種行為嗎? 只有因為Symfony需要(因為未知原因)而擁有一個空的UserInterface
類似乎沒用。
我猜你沒有將UserInterface的命名空間導入你的用戶類(我猜它是一個User類,因為你沒有提到它):
use Symfony\Component\Security\Core\User\UserInterface;
class User implements UserInterface
{
}
閱讀官方文檔中的PHP命名空間 。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.