contao / contao

Contao Open Source CMS
https://contao.org
GNU Lesser General Public License v3.0
340 stars 158 forks source link

Map the app entities by default #1434

Closed qzminski closed 4 years ago

qzminski commented 4 years ago

Description The Doctrine entities inside App namespace could probably be mapped by default. This requires some changes in the current config skeleton: https://github.com/contao/contao/blob/master/manager-bundle/src/Resources/skeleton/config/config.yml#L54

Example As of now I have to provide this configuration on my own:

doctrine:
    orm:
        mappings:
            App:
                type: annotation
                dir: '%kernel.project_dir%/src/Entity'
                is_bundle: false
                prefix: App\Entity
                alias: App

/cc @aschempp

m-vo commented 4 years ago

I've put that in every project as well. Not sure if the Entity directory needs to exist for this to work.

leofeyer commented 4 years ago

As discussed in Mumble on August 27th, we cannot add this into the config.yml, because it will fail if there is no Entity folder. However, we could add a compiler pass that checks the existing configuration and dynamically adds the mapping if the Entity folder exists.

Toflar commented 4 years ago

I don't think we can do this. See https://github.com/symfony/doctrine-bridge/blob/4e6cfe4c9a1e6e3b7ff8f1e0e0996bf138ee1205/DependencyInjection/AbstractDoctrineExtension.php#L226

aschempp commented 4 years ago

see #2232