B
B
BonBon Slick2018-05-06 18:57:18
symfony
BonBon Slick, 2018-05-06 18:57:18

Split the mapping structure into folders and subfolders?

According to the documentation, all files that are in the folder are mapped by files. However, what if I already have 400+ files there? I would like to split it into folders and subfolders, but it gives an error that there is no mapping file if we transfer it to the sub directory of the mapping folder.
At the moment, taken from here https://stackoverflow.com/questions/38008997/can-i... so far I do this, for each pack of related mappings, I create another mapping in the configuration.

mappings:
        User:
          is_bundle: false
          type: xml
          dir: '%kernel.project_dir%/src/Infrastructure/Mappings/User'
          prefix: 'App\Domain\User'
          alias: User
     Role:
          is_bundle: false
          type: xml
          dir: '%kernel.project_dir%/src/Infrastructure/Mappings/Role'
          prefix: 'App\Domain\Role'
          alias: Role
...

However, this is also quite a lot, it still comes out dirty.
Perhaps you can somehow add, change, fix the file mapping locator?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
voronkovich, 2018-05-06
@BonBonSlick

See an example here: https://symfony.com/doc/current/configuration/micr...
It shows how to load a container configuration using PHP (see the configureContainer method)

// Сначала вам нужно прочитать все директории с файлами мэппинга
// и сделать из них массив
foreach ($paths as $dir) {
    $mappings[$dir] = [
        'is_bundle' => false,
        // ...
    ];
}

// А потом загрузить его в контейнер
$c->loadFromExtension('doctrine', [
    'orm' => [
        'mappings' => $mappings
    ]
)]);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question