Php Symfony升级到3.3服务参数错误
升级到Symfony 3.3后。我明白了: PHP致命错误:未捕获 Symfony\Component\DependencyInjection\Exception\InvalidArgumentException: 在的方法“setRoles()”的参数中找到无效的键“roles” 服务“authbundle.auth.repository.role”:仅整数或$named 允许使用参数。在里面 /app/vendor/symfony/symfony/src/symfony/Component/DependencyInjection/Compiler/ResolveNamedArgumentsPass.php:47 这是我的服务定义:Php Symfony升级到3.3服务参数错误,php,symfony,Php,Symfony,升级到Symfony 3.3后。我明白了: PHP致命错误:未捕获 Symfony\Component\DependencyInjection\Exception\InvalidArgumentException: 在的方法“setRoles()”的参数中找到无效的键“roles” 服务“authbundle.auth.repository.role”:仅整数或$named 允许使用参数。在里面 /app/vendor/symfony/symfony/src/symfony/Component/
authbundle.auth.repository.role:
class: AuthBundle\Auth\Repository\RoleRepository
在这里,我将在AuthExtension
类中向该服务注入一个自定义配置:
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']]);
}
有什么想法吗?结果是我的方法调用不正确,我不得不从
$roleRepositoryDef->addMethodCall('setRoles',['roles'=>$config['roles']])代码>
$roleRepositoryDef->addMethodCall('setRoles',[$config['roles']])代码>
因此,这个参数不是出于好奇而命名的,您的原始代码工作了吗?换句话说,升级到3.3真的破坏了你的代码吗?是的,我在那里呆了一两个月,工作正常,测试确保它工作,等等,在3.1->3.3更新后肯定停止工作。文档声明方法和构造函数参数中的[BC break]非数字键从未被支持,现在被禁止。如果您碰巧有一个,请将其移除。。