无法通过原则验证测试

时间:2016-04-18 12:27:30

标签: php validation orm doctrine

我有5个实体和5个映射,我已经完成了大部分的orm映射,而且ik主要工作,但我似乎无法通过验证测试:php bin/console doctrine:schema:validate

这些是我的映射:

file:Organisation.orm.yml

AppBundle\Entity\Organisation:
type: entity
id:
    id:
        type: integer
        generator: { strategy: AUTO }
fields:
    # irrelevant fiels
    # ...
oneToOne:
    creator:
        targetEntity: Person
        inversedBy: organisation
        joinColumn:
            name: creator_id
            referencedColumnName: id
oneToMany:
    vacancies:
        targetEntity: Vacancy
        mappedBy: id

file:Person.orm.yml

AppBundle\Entity\Person:
type: entity
id:
    id:
        type: integer
        generator: { strategy: AUTO }
fields:
    # irrelevant fiels
    # ...
oneToOne:
    organisation:
        targetEntity: Organisation
        mappedBy: creator
oneToMany:
    testimonials:
        targetEntity: Testimonial
        mappedBy: receiver_id
manyToMany:
    skills:
        targetEntity: Skill
        mappedBy: null
        joinTable:
            name: person_has_skill
            joinColumns:
                -
                    name: person_id
                    referencedColumnName: id
            inverseJoinColumns:
                -
                    name: skill_id
                    referencedColumnName: id

file:Skill.orm.yml

AppBundle\Entity\Skill:
type: entity
id:
    id:
        type: integer
        generator: { strategy: AUTO }
fields:
    name:
        type: string
        length: 100
manyToOne:
    parent:
        nullable: true
        targetEntity: Skill
        joinColumn:
            name: parent_id
            referencedColumnName: id

file:Testimonial.orm.yml

AppBundle\Entity\Testimonial:
type: entity
id:
    id:
        type: integer
        generator: { strategy: AUTO }
fields:
    value:
        type: text
    approved:
        type: boolean
        nullable: true
manyToOne:
    sender:
        targetEntity: Person
        joinColumn:
            name: sender_id
            referencedColumnName: id
    receiver:
        targetEntity: Person
        joinColumn:
            name: receiver_id
            referencedColumnName: id

档案:Vacancy.orm.yml

AppBundle\Entity\Vacancy:
type: entity
id:
    id:
        type: integer
        generator: { strategy: AUTO }
fields:
    title:
        type: string
        length: 100
    description:
        type: text
    startdate:
        type: datetime
    enddate:
        type: datetime
manyToOne:
    organisation:
        targetEntity: Organisation
        inversedBy: vacancies
        joinColumn:
            name: organisation_id
            referencedColumnName: id
manyToMany:
    skills:
        targetEntity: Skill
        nullable: true
        mappedBy: null
        joinTable:
            name: vacancy_has_skill
            joinColumns:
                -
                    name: vacancy_id
                    referencedColumnName: id
            inverseJoinColumns:
                -
                    name: skill_id
                    referencedColumnName: id

这是我的验证错误: https://i.imgur.com/AqhRxxQ.jpg 我已经好几天了,我似乎无法找到解决方案。很想听到知道更多的人的消息!

1 个答案:

答案 0 :(得分:0)

OP在这里找到答案......

在Organisation.orm.yml中我必须设置:

OnetoMany:
    vacancies:
        targetEntity: Vacancy
        mappedBy: organisation