A
A
Anton2017-04-20 15:36:59
symfony
Anton, 2017-04-20 15:36:59

In doctrine:mapping:import how to customize imports based on table prefixes?

I just can't find a solution (and is there one at all)?
There are about a dozen bundles. Each of which corresponds to a set of tables in the database. They are separated by prefixes, for example:

BlogBundle = blog_document, blog_comment...
ForumBundle = forum_document, forum_comment...
RegBundle = reg_document, reg_comment...

I work with tables in phpMyAdmin and then import the changes using:
php bin/console doctrine:mapping:import --force BlogBundle yml --filter="BlogComment"

(so much faster and more convenient than writing yml)
And doctrine, by itself creates entities and relationships with prefixes, that is: BlogComment, BlogDocument ...
But the following would be more convenient: in the import command, you set the table prefix so that it ignores it.
For example something like:
php bin/console doctrine:mapping:import --force BlogBundle yml --filter="Comment" --tablePrefix="blog"

And at the output of the entity and the relationship: Comment, Document. And the table prefix would be indicated in the configuration:
# Document.orm.yml
AppBundle\Entity\Document:
    type: entity
    table: exp_document

Simple, convenient, but I did not find it. Mb someone met? Or any ideas how easy it is to implement?
ps the only catch is with links like blog_document -> reg_document. I have these entities in different bundles, but you can’t explain this normally to the doctrine ...

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Anton, 2017-04-25
@fattan

the very idea described in the question turned out to be "not very". Changed the approach to the classic one:
1. Creating models, 2. describing links in the config, 3. generating tables in the database

F
Fortop, 2017-05-20
@Fortop

In fact, you can configure Doctrine to ignore prefixes.
To do this, you need to write an event listener loadClassMetadata
Which will prescribe or ignore prefixes for certain tables

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question