Symfony upgrade to 3.3 service argument error

Viewed 989

After upgrading to Symfony 3.3. I get this:

PHP Fatal error: Uncaught Symfony\Component\DependencyInjection\Exception\InvalidArgumentException: Invalid key "roles" found in arguments of method "setRoles()" for service "authbundle.auth.repository.role": only integer or $named arguments are allowed. in /app/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Compiler/ResolveNamedArgumentsPass.php:47

This is my service definition:

authbundle.auth.repository.role:
  class: AuthBundle\Auth\Repository\RoleRepository

And here I am injecting a custom config into that service in the AuthExtension class:

public function load(array $configs, ContainerBuilder $container)
{
    $loader = new YamlFileLoader($container, new FileLocator(dirname(__DIR__).'/Resources/config'));
    $configuration = new Configuration();
    $config = $this->processConfiguration($configuration, $configs);
    $loader->load('services.yml');

    $roleRepositoryDef = $container->getDefinition('authbundle.auth.repository.role');
    $roleRepositoryDef->addMethodCall('setRoles', ['roles' => $config['roles']]);
}

Any ideas please?

1 Answers
Related