我正在使用YAML在Symfony 4中配置Doctrine ORM映射 . 有没有办法在其配置中手动指定实体的类名?看起来实体的类名是基于yml配置文件的名称生成的,并且无法覆盖它 .
假设我有一个名为 Foo.orm.yml
的映射配置 . Doctrine会认为实体类的实际名称是 Foo
. 但是,如果我希望 Foo.orm.yml
文件将表映射到类 Bar
,该怎么办?所以我在思考配置中的 class
选项,但在互联网上找不到任何东西 .
#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中不起作用 .
1 回答
将 Bar 更改为 AppBundle\Entity\Bar