I have custom mapping settings in my Symfony3 project for Doctrine entities like this:
MyModel:
type: yml
dir: %kernel.root_dir%/../src/AppBundle/Resources/config/doctrine/MyModel
prefix: MyProject\MyModel\Model
is_bundle: false
Let's assume I have an entity MyProject\MyModel\Model\SubNamespace\MyEntity. Now, I have to put its yml mapping in %kernel.root_dir%/../src/AppBundle/Resources/config/doctrine/MyModel/SubNamespace.MyEntity.orm.yml, and it works fine.
Can I configure Doctrine to be able to organize mapping files in subfolders instead of file names being a concatenation of parts of namespace after prefix?
In this case if would be %kernel.root_dir%/../src/AppBundle/Resources/config/doctrine/MyModel/SubNamespace/MyEntity.orm.yml
The reason is that mapping directory is growing and it's getting hard to find any particular file inside.
Of course, it's not a solution to make a configuration for every subfolder. ;-)
Looking at the source code, there's nothing to handle subfolders. But then the trick could be to add each folder in a different "mapping", as far I know those don't have to stick to your Symfony bundles:
doctrine:
# ...
orm:
# ...
mappings:
AcmeBundleFoo:
type: yml
dir: AcmeBundle/Resources/doctrine/Foo
AcmeBundleBar:
type: yml
is_prefix: false # you are free to let Symfony guess it or to be explicit
dir: AcmeBundle/Resources/doctrine/Bar
A little verbose, but it should work given yout folder structure is src/AcmeBundle/Resources indeed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With