我正在尝试遵循此页面上教义文档的建议- 使用 ArrayCollection 初始化一个类成员。对于文档中给出的示例,一切都很好。我正在尝试使用继承的类来执行此操作,但收到错误消息:
Class Doctrine\Common\Collections\ArrayCollection is not a valid entity or mapped super class
继承类:
/**
* @Entity
* @InheritanceType("JOINED")
* @DiscriminatorColumn(name="discr", type="string")
* @DiscriminatorMap({"user" = "App_User", "group" = "App_Group"})
*/
abstract class App_Acl_Role_Abstract implements Zend_Acl_Role_Interface {
/**
* @ManyToOne(targetEntity="App_Acl_Role_Abstract", inversedBy="children", cascade={"persist"})
*/
private $parents;
/**
* @OneToMany(targetEntity="App_Acl_Role_Abstract", mappedBy="parents", cascade={"persist"})
*/
private $children;
public function __construct()
{
$this->parents = new Doctrine\Common\Collections\ArrayCollection();
$this->children = new Doctrine\Common\Collections\ArrayCollection();
}
}
继承类:
/**
* @Entity
* @Table(name="App_User")
*/
class App_User extends App_Acl_Role_Abstract
{
...
}
当我将构造函数移动到继承类时,一切正常。但是将它们放在继承的抽象类中会更整洁。为什么它不起作用?可能吗?