Symfony 4 импортирует .yaml услуги автопроводки - PullRequest
0 голосов
/ 28 ноября 2018

services.yaml

imports:
    - { resource: commands.yaml }

parameters:

services:
    _defaults:
        autowire: true     
        autoconfigure: true 
        public: false       

    App\:
        resource: '../src/*'
        exclude: '../src/{Entity,Migrations,Tests}'

    App\Controller\:
        resource: '../src/Controller'
        tags: ['controller.service_arguments']

    App\Service\ExampleService:
        arguments:
            - '%env(URL)%'
            - '@doctrine.orm.entity_manager'

commands.yaml

parameters:

services:

    App\Command\Import\ExampleCommand:
        arguments:
            - '@App\Service\ExampleService'
            - '@monolog.logger.example'
            - '@parameter_bag'

Когда я запускаю ExampleCommand экземпляр монолога по умолчанию с каналом по умолчанию.Я думаю, что причиной того, почему ExampleCommand получить другой регистратор является автоматическое подключение.Когда я комментирую - { resource: commands.yaml } команда запускается без ошибок.У меня есть службы Мэнни, и мне нужно разделить конфигурацию.

Все правильно без импорта:

services.yaml

imports:
    - { resource: commands.yaml }

parameters:

services:
    _defaults:
        autowire: true     
        autoconfigure: true 
        public: false       

    App\:
        resource: '../src/*'
        exclude: '../src/{Entity,Migrations,Tests}'

    App\Controller\:
        resource: '../src/Controller'
        tags: ['controller.service_arguments']

    App\Service\ExampleService:
        arguments:
            - '%env(URL)%'
            - '@doctrine.orm.entity_manager'  

    App\Command\Import\ExampleCommand:
        arguments:
            - '@App\Service\ExampleService'
            - '@monolog.logger.example'
            - '@parameter_bag'

Есть ли способ со многими импортированными .yaml?

...