Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Single Table Inheritance and Yaml configuration

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?

like image 833
Krzysztof Lenda Avatar asked Nov 02 '11 10:11

Krzysztof Lenda


2 Answers

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: {  }
like image 69
DEY Avatar answered Nov 12 '22 09:11

DEY


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?

like image 36
Vladislav Rastrusny Avatar answered Nov 12 '22 10:11

Vladislav Rastrusny