Сначала мой файл конфигурации выглядел так:
# config/services.yaml
services:
_defaults:
autowire: true # Automatically injects dependencies in your services.
autoconfigure: true # Automatically registers your services as commands, event subscribers, etc.
public: false # Allows optimizing the container by removing unused services; this also means fetching services directly from the container via $container->get() won't work. The best practice is to be explicit about your dependencies anyway.
App\:
resource: '../src/*'
exclude: '../src/{DBAL/*,Migrations,Form,Tests,Kernel.php,Entity/BaseEntity.php,Repository/BaseRepository.php}'
App\EventDispatcher\Event\Api\EntityEvent:
class: App\EventDispatcher\Event\Api\EntityEvent
public: true
Я перенес некоторые конфигурации в другой файл:
# config/services.yaml
imports:
- { resource: 'services/new_config_file.yaml' } # <------ NEW
services:
_defaults:
autowire: true # Automatically injects dependencies in your services.
autoconfigure: true # Automatically registers your services as commands, event subscribers, etc.
public: false # Allows optimizing the container by removing unused services; this also means fetching services directly from the container via $container->get() won't work. The best practice is to be explicit about your dependencies anyway.
App\:
resource: '../src/*'
exclude: '../src/{DBAL/*,Migrations,Form,Tests,Kernel.php,Entity/BaseEntity.php,Repository/BaseRepository.php}'
# THIS BLOCK IS MOVED
# App\EventDispatcher\Event\Api\EntityEvent:
# class: App\EventDispatcher\Event\Api\EntityEvent
# public: true
В новом файле конфигурации:
# config/services/new_config_file.yaml
services:
_defaults:
autowire: true # Automatically injects dependencies in your services.
autoconfigure: true # Automatically registers your services as commands, event subscribers, etc.
public: false # Allows optimizing the container by removing unused services; this also means fetching services directly from the container via $container->get() won't work. The best practice is to be explicit about your dependencies anyway.
App\:
resource: '../../src/*'
exclude: '../../src/{DBAL/*,Migrations,Form,Tests,Kernel.php,Entity/BaseEntity.php,Repository/BaseRepository.php}'
App\EventDispatcher\Event\Api\EntityEvent:
class: App\EventDispatcher\Event\Api\EntityEvent
public: true
В результате я получаю сообщение об ошибке:
{
"status": "error",
"message": "The controller for URI \"/api/broker/\" is not callable. The \"App\\EventDispatcher\\Event\\Api\\EntityEvent\" service or alias has been removed or inlined when the container was compiled. You should either make it public, or stop using the container directly and use dependency injection instead."
}
Я понимаю, что можно импортировать только параметры? В исходном коде он проверяет наличие ключа службы