[英]Specify entity class name in Symfony Doctrine ORM
我正在使用YAML在Symfony 4中配置Doctrine ORM映射。是否有任何方法可以在其配置中手動指定實體的類名? 似乎實體的類名稱是根據yml配置文件的名稱生成的,因此無法覆蓋它。
說我有一個名為Foo.orm.yml
的映射配置。 教義將認為實體類的實際名稱是Foo
。 但是,如果我希望Foo.orm.yml
文件將該表映射到Bar
類上,該怎么辦? 所以我在考慮配置中的class
選項之class
東西,但是在Internet上什么都沒找到。
#file Foo.orm.yml
Bar:
class: Bar
type: entity
table: bar
id:
id:
type: integer
generator: { strategy: NONE }
fields:
foo:
type: string
bar:
type: boolean
XML映射具有name
選項: http : //docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/xml-mapping.html在YAML中不起作用。
將Bar更改為AppBundle \\ Entity \\ Bar
AppBundle\Entity\Bar:
type: entity
table: bar
id:
id:
type: integer
generator: { strategy: NONE }
fields:
foo:
type: string
bar:
type: boolean
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.