单表继承和Yaml配置

发布于 2024-12-13 09:26:11 字数 122 浏览 1 评论 0原文

我想在我的项目中使用 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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

沦落红尘 2024-12-20 09:26:11

好的内置转换器可以挽救生命。

为了节省时间,将继承转换为 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: {  }

Okay built-in converter saves life.

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: {  }
风轻花落早 2024-12-20 09:26:11

Here is an example of YAML markup:

Entities config files should be put into src/Acme/StoreBundle/Resources/config/doctrine/<EntityName>.orm.yml according to reference.

Also built-in converter can be used: how to model inheritance in doctrine2 with yaml?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文