我试图将接口用作"targetEntity".简单的代码应该解释我打算做什么
接口:
namespace Project\Entity;
interface AnimalInterface{
}
Run Code Online (Sandbox Code Playgroud)
猫:
namespace Project\Entity;
use Doctrine\ORM\Mapping as ORM;
use Project\Entity\AnimalInterface;
/**
* Represents an Invoice.
*
* @ORM\Entity
* @ORM\Table(name="Cat")
*/
class Cat implements AnimalInterface {
/**
* @var int
* @ORM\Id @ORM\Column(type="integer", name="id")
* @ORM\GeneratedValue
*/
protected $id;
}
Run Code Online (Sandbox Code Playgroud)
狗:
namespace Project\Entity;
use Doctrine\ORM\Mapping as ORM;
use Project\Entity\AnimalInterface;
/**
* @ORM\Entity
* @ORM\Table(name="Dog")
*/
class Dog implements AnimalInterface {
/**
* @var int
* @ORM\Id @ORM\Column(type="integer", name="id")
* @ORM\GeneratedValue
*/
protected $id;
} …Run Code Online (Sandbox Code Playgroud)