本文介绍了单表继承和 Yaml 配置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在我的项目中使用 symfony2/doctrine 的单表继承,但我找不到任何带有 yaml 配置的工作示例.在官方文档中,仅提供注释配置.我找到了 xml 示例,但我想使用 yaml 配置.有人可以帮忙分享一些工作代码吗?
I want to use in my project Single Table Inheritance for symfony2/doctrine, but I can't find any working examples with yaml configuration for it. In official documentation there is only annotation configuration presented. I found xml examples, but I want to use yaml configuration. Can somebody help and share with some working code?
推荐答案
好的内置转换器救命.
为了节省时间,这里将继承转换为 yaml 的示例:
In order to save time this an example of inheritance converted into yaml :
#file: Resources/config/doctrine/Person.orm.yml
Person:
type: entity
table: null
fields:
id:
type: integer
id: true
generator:
strategy: AUTO
inheritanceType: SINGLE_TABLE
discriminatorColumn:
name: discr
type: string
length: 255
discriminatorMap:
person: Person
employee: Employee
lifecycleCallbacks: { }
#file: Resources/config/doctrine/Employee.orm.yml
Employee:
type: entity
table: null
lifecycleCallbacks: { }
这篇关于单表继承和 Yaml 配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!