Symfony access control security.yml中的表达式语言不用于路由

Symfony access control security.yml中的表达式语言不用于路由,symfony,symfony-security,Symfony,Symfony Security,我在访问控制(symfony 3.3.)中使用参数时遇到问题*: 堆栈跟踪错误: A string value must be composed of strings and/or numbers, but found parameter "internal_host" of type array inside string value "has_role('ROLE_API_USER') or request.getHost() in '%

我在访问控制(symfony 3.3.)中使用参数时遇到问题*:

堆栈跟踪错误

A string value must be composed of strings and/or numbers, but found parameter "internal_host" of type array inside string value "has_role('ROLE_API_USER') or request.getHost() in '%internal_host%'"
我尝试了另一种方法,如参数('internal_host')中的
request.getHost()
或容器中的
request.getHost().getParameter('internal_host')
,但我收到了错误消息,如
函数“parameter”在位置51附近不存在,因为表达式在参数中有_角色('role_API_USER')或request.getHost()('internal_host')。
(容器服务的消息相同)


如何使用expression language访问控制中的参数?

如果使用Symfony 3,可以尝试:

-
    path: ^/api
    allow_if: "has_role('ROLE_API_USER') or request.getHost() in ['%internal_host%']"

cf

可能重复的不重复这是为了安全访问控制而不是路由,我已经尝试过,但没有成功解决方案兄弟!是的,我已经尝试过,但不工作,因为%internal\u host%是一个参数,您尝试过使用吗?我想它可以用于内部主机我有相同的错误:函数表达式
在位置51附近不存在“env”,它在env('internal_host')中有\u role('role\u API\u USER')或request.getHost()
找到解决方案了吗??
-
    path: ^/api
    allow_if: "has_role('ROLE_API_USER') or request.getHost() in ['%internal_host%']"