2012-12-14 4 views
3

Symfony 2.1을 사용하여 고객 사례 관리 시스템을 만들고 있습니다. 해결할 수없는 이상한 문제가 발생했습니다. 나는 응용 프로그램의 일부가 해당 인터페이스를 요구하고 아무 생각이Symfony2 클래스 UserInterface가 존재하지 않습니다.

"Class HSW\AshaBundle\Entity\UserInterface does not exist"
500 Internal Server Error

: 나는 CustomerCaseController으로 showAction을 어떤 이유로, 나는 다음과 같은 오류가 발생합니다. UserInterface.php 클래스를 만들면 문제가으로 사라지고 모든 것이 작동합니다. showActionUserInterface이 필요한 이유는 무엇입니까?

내가 어떻게 든 showController 코드의이 부분에 관련하는 문제가 좁혀

:

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

을 내가 가지고있는 다음과 같은 기관 :

  • User
  • (로그인 및 제출 경우에)
  • Customer (고객의 경우)
  • CustomerCase (사례)

CustomerCase는 다음과 같은 방법으로 CustomerUser 단체와 ManyToOne 관계가 있습니다

// SRC/HSW/AshaBundle/법인/CustomerCase.php 네임 스페이스 HSW \ AshaBundle \ 엔티티;

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/법인/CustomerCase.php 네임 스페이스 HSW \ AshaBundle \ 엔티티;

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 사이입니다 ( UserInterface 없이는 showAction이 작동 함).

이 동작을 디버깅 할 수있는 사람이 있습니까? Symfony가 (알 수없는 이유로)를 요구하기 때문에 비어있는 UserInterface 클래스를 갖는 것만으로는 쓸모없는 것처럼 보입니다.

+0

게시물을 편집하고 네임 스페이스 선언을 표시하고 CustomerCase 및 User 엔티티에서 문을 사용할 수 있습니까? – Mike

+0

감사합니다. 마이크, 방금 두 엔티티의 시작 부분을 추가했습니다. AdvancedUserInterface를 로그인 용으로 사용하고 있습니다 (전자 메일로 로그인 허용). 이것이 어떻게 든 이러한 문제의 원인이 될 수 있습니까? – user1903831

답변

0

은 내가 (당신이 그것을 언급하지 않았기 때문에이 사용자 클래스의 추측하고있어) 당신이 당신의 사용자 클래스로의 네임 스페이스를 UserInterface 가져 오지 않았다 같은데요 :

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

class User implements UserInterface 
{ 
} 

PHP namespaces in the official docs에 읽기.

+1

안녕 Jakub 고마워요! 이것은 실제로 상황을 고치는 것처럼 보였다. 내 User 클래스가 UserInterface를 직접 구현하지 않았기 때문에 (처음에는 AdvancedUserInterface를 사용함) 약간의 회의론자였습니다. 나는이 특정 문제를 일으킨 것에 대해 아직도 혼란 스럽다.UserInterface 네임 스페이스를 가져 오지 않고도 로그인/로그 아웃을 CustomerCase에 createAction 할 수있었습니다. – user1903831

관련 문제