I’m making a customer case management system with Symfony 2.1 and I’ve stumbled on this weird problem I’m unable to resolve. For some reason when I do the showAction with CustomerCaseController, I get the following error:
“Class HSW\AshaBundle\Entity\UserInterface does not exist”
500 Internal Server Error
I have no idea which part of the application is requiring that interface. If I create an empty UserInterface.php class, the problem goes away and everything works. Why does the showAction require UserInterface?
I have narrowed the problem to somehow relate to this piece of code in the showController:
$customercase = $this->getDoctrine() ->getRepository('HSWAshaBundle:CustomerCase') ->find($id);
I have the following entities:
User(for login and submitting cases)Customer(for Customers)CustomerCase(for cases).
The CustomerCase has a ManyToOne relation with Customer and User entities in the following way:
// src/HSW/AshaBundle/Entity/CustomerCase.php
namespace 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
namespace 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....
Could the relationship with the User entity affect this somehow? That’s the only visible difference I see between CustomerCase.php and Customer.php (where showAction works without UserInterface).
Can someone help me to debug this behaviour?. It seems really useless to have an empty UserInterface class only because Symfony requires is (for an unknown reason).
I’m guessing you didn’t import UserInterface‘s namespace into your user class (I’m guessing it’s a User class since you didn’t mention it):
Read on PHP namespaces in the official docs.