Gedmo树扩展:无法找到祖先/父子关系

时间:2014-04-10 13:39:39

标签: symfony doctrine-orm tree doctrine-extensions

我正在尝试将 Gedmo 扩展名用 YAML 格式,但是当我尝试更新架构时,它会返回以下错误:

[Gedmo\Exception\InvalidMappingException]
Unable to find ancestor/parent child relation through ancestor field - [parent] in class -

以下代码是 MyEntity.orm.yml 文件:

Project\MyBundle\Entity\MyEntity:
    type: entity
    repositoryClass: Gedmo\Tree\Entity\Repository\NestedTreeRepository
    gedmo:
        tree:
            type: nested
    id:
        id:
            type: string
            nullable: false
            generator:
                strategy: UUID
    fields:
        name:
            type: string
            length: 200
        locale:
            type: string
            length: 6
        lft:
            type: integer
            gedmo:
                - treeLeft
        lvl:
            type: integer
            gedmo:
                - treeLevel
        rgt:
            type: integer
            gedmo:
                - treeRight
        root:
            type: string
            nullable: true
            gedmo:
                - treeRoot

    manyToOne:
        parent:
            targetEntity: Project\MyBundle\Model\MyEntityInterface
            inversedBy: children
            joinColumn:
                name: parent_id
                referencedColumnName: id
                onDelete: CASCADE
            gedmo:
                - treeParent
    oneToMany:
        children:
            targetEntity: Project\MyBundle\Model\MyEntityInterface
            mappedBy: parent
            orderBy:
                lft: ASC

1 个答案:

答案 0 :(得分:1)

它不能是接口,它必须是一个实体

查找

  

targetEntity:Project \ MyBundle \ Model \ MyEntityInterface

更改为:

  

targetEntity:Project \ MyBundle \ Entity \ MyEntity