我遇到了Doctrine MongoDB ODM的问题。场景非常简单(我认为)。 我有一套带有COLLECTION_PER_CLASS继承模型(Base,Product等)的文档。这一切都运作良好,我可以像往常一样坚持对象。
/**
* @ODM\Document(collection="content_base")
* @ODM\InheritanceType("COLLECTION_PER_CLASS")
*/
class Base {
/**
* @ODM\Document(collection="content_products")
*/
class Product extends Base {
现在,我有另一个Document(Item),我想为继承的Document创建ReferenceOne:
/**
* @ODM\ReferenceOne(targetDocument="Base")
*/
private $content;
这就是我遇到问题的地方,因为Doctrine ClassLoader抱怨类Base被重新声明:
Fatal error: include(): Cannot redeclare class content\documents\types\base in /vendor/composer/ClassLoader.php on line 183
我有点困惑为什么这会成为一个问题,或者其他什么是正确的做法?
更新
我刚刚注意到,如果我从ReferenceOne注释中删除'targetDocument',我会得到我想要的结果。这是正确的方法吗?
谢谢, 格雷格