A
A
Alexey Vinogradov2020-10-06 15:25:29
symfony
Alexey Vinogradov, 2020-10-06 15:25:29

How to create an entity in a non-standard way?

Hello, there are such orm settings in -

doctrine.yaml


orm:
        auto_generate_proxy_classes: "%kernel.debug%"
#        default_entity_manager: oracle_db
        entity_managers:
            oracle_db:
                connection: oracle_db
                naming_strategy: doctrine.orm.naming_strategy.underscore
                auto_mapping: true
                mappings:
                    App:
                        is_bundle: false
                        type: annotation
                        dir: '%kernel.project_dir%/src/Common/Entity'
                        prefix: 'App\Common\Entity'
                        alias: App\Common

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

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


And it so happened that all entities are stored articulated in folders -
App\Common\Entity
App\OracleDB\Entity
App\Cecs\Entity

But when the php bin/console make:entity command is executed, files are created in the App/Entity section.
The question is how can I use this command to create an entity in the directory I need with the correct namespace, for example App\OracleDB\Entity.
Is it only by hand?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
BoShurik, 2020-10-06
@Vinstrok

This is not possible
. As an option (if you still have all the entities in the Entity namespace, because it is hardcoded) - configure the bundle before each generation, and then return it back

maker:
    root_namespace: 'App\Common'

Don't forget to add the namespace to the doctrine's config before generating it, because otherwise, you will generate an entity class and a repository, but you will not be allowed to add fields.
mappings:
    App:
        is_bundle: false
        type: annotation
        dir: '%kernel.project_dir%/src/Entity'
        prefix: 'App\Entity'
        alias: App
    AppСommon:
        is_bundle: false
        type: annotation
        dir: '%kernel.project_dir%/src/Common/Entity'
        prefix: 'App\Common\Entity'
        alias: AppСommon

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question