Question

I'm trying to use tree extension of Gedmo with YAML format but when I try to update the schema it returns the following error:

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

The following code is the MyEntity.orm.yml file:

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
Was it helpful?

Solution

It cant be interface, it has to be a entity

find

targetEntity: Project\MyBundle\Model\MyEntityInterface

change to:

targetEntity: Project\MyBundle\Entity\MyEntity

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top