Reputation: 2736
I'm using YAML for configuring the Doctrine ORM mappings in Symfony 4. Is there any way to specify the class name of an entity manually in its config? It seems like the entity's class name is generated based on the name of the yml config file and there is no way to override it.
Say I have a mapping config called Foo.orm.yml
. Doctrine is going to think that the actual name of the entity class is Foo
. But what if I want the Foo.orm.yml
file to map the table onto the class Bar
? So I was thinking about something like the class
option inside the config, but haven't found anything on the 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 mappings have the name
option though: http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/xml-mapping.html which doesn't work in YAML.
Upvotes: 0
Views: 484
Reputation: 75
Change Bar to AppBundle\Entity\Bar
AppBundle\Entity\Bar:
type: entity
table: bar
id:
id:
type: integer
generator: { strategy: NONE }
fields:
foo:
type: string
bar:
type: boolean
Upvotes: 1