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?
我想在我的项目单表继承中使用symfony2 / doctrine,但我找不到任何有yaml配置的工作示例。在官方文档中,仅提供了注释配置。我找到了xml示例,但我想使用yaml配置。有人可以帮助和分享一些工作代码吗?
2 个解决方案
#1
12
Okay built-in converter saves life.
好的内置转换器可以挽救生命。
In order to save time this an example of inheritance converted into yaml :
为了节省时间,这个转换为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: { }
#2
1
Here is an example of YAML markup:
以下是YAML标记的示例:
Entities config files should be put into src/Acme/StoreBundle/Resources/config/doctrine/<EntityName>.orm.yml
according to reference.
根据参考,实体配置文件应放入src / Acme / StoreBundle / Resources / config / doctrine /
Also built-in converter can be used: how to model inheritance in doctrine2 with yaml?
还可以使用内置转换器:如何使用yaml在doctrine2中建模继承?
#1
12
Okay built-in converter saves life.
好的内置转换器可以挽救生命。
In order to save time this an example of inheritance converted into yaml :
为了节省时间,这个转换为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: { }
#2
1
Here is an example of YAML markup:
以下是YAML标记的示例:
Entities config files should be put into src/Acme/StoreBundle/Resources/config/doctrine/<EntityName>.orm.yml
according to reference.
根据参考,实体配置文件应放入src / Acme / StoreBundle / Resources / config / doctrine /
Also built-in converter can be used: how to model inheritance in doctrine2 with yaml?
还可以使用内置转换器:如何使用yaml在doctrine2中建模继承?