My config/service.yaml contains several services that have huge configuration. Now, I want to move the configuration of that services to a separate file.
I tried to do like this:
At the end of service.yaml:
imports:
- { resource: 'packages/custom_service.yaml' }
config/packages/custom_service.yaml:
services:
App\Service\CustomService:
arguments:
$forms:
- location: 'room1'
id: 43543
- location: 'room2'
id: 6476546
- location: 'room3'
id: 121231
...
src/Service/CustomService.php:
/**
* @var array
*/
protected $forms;
public function __construct(array $forms)
{
$this->forms = $forms;
}
But when I try to autowire in some Controller, I am getting this error:
Cannot resolve argument $customService of "App\Controller\CustomController::customAction()": Cannot autowire service "App\Service\CustomService": argument "$forms" of method "__construct()" is type-hinted "array", you should configure its value explicitly.
But if I remove type hint, Then i get this error:
Cannot resolve argument $customService of "App\Controller\CustomController::customAction()": Cannot autowire service "App\Service\CustomService": argument "$forms" of method "__construct()" has no type-hint, you should configure its value explicitly.