我正在尝试将 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
答案 0 :(得分:1)
它不能是接口,它必须是一个实体
查找
targetEntity:Project \ MyBundle \ Model \ MyEntityInterface
更改为:
targetEntity:Project \ MyBundle \ Entity \ MyEntity