2011-11-02 89 views
11

我想在Symfony2中/教義我的項目單表繼承使用,但我不能找到它YAML配置任何工作的例子。在官方文檔中,僅提供了註釋配置。我找到了xml示例,但我想使用yaml配置。有人可以幫助和分享一些工作代碼嗎?單表繼承和YAML配置

回答

1

這裏是an example of YAML markup

實體配置文件應根據reference投入src/Acme/StoreBundle/Resources/config/doctrine/<EntityName>.orm.yml

還內置轉換器可用於:how to model inheritance in doctrine2 with yaml?

+0

TX,我看過這個,我用YAML標籤在我的應用程序的權利,但我有[繼承問題映射](http://www.doctrine-project.org/docs/orm/2.1/en/reference/inheritance-mapping.html)。我需要yaml標記中的[7.2單表繼承](http://www.doctrine-project.org/docs/orm/2.1/en/reference/inheritance-mapping.html#single-table-inheritance)示例。 –

+0

@Krzysztof倫達:您可以使用轉換器:http://stackoverflow.com/questions/6265105/how-to-model-inheritance-in-doctrine2-with-yaml –

+0

謝謝。這個轉換器似乎是非常有用的工具 - 我以前不知道它。我想,我現在可以處理它! –

12

奧凱內置轉換器可以節省生活。

爲了節省時間繼承這樣的一個例子轉換成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: { } 
+0

請注意,在symfony 2.2中,除非手動創建類,否則控制檯的命令'doctrine:generate:entities'不會生成類。 –