函数 "is_expr_granted" 不存在

The function "is_expr_granted" does not exist

我正在尝试安装新的 Admingenerator Bundle (symfony2admingenerator/generator-bundle)。一些生成的模板(如 *List/results.html.twig)需要 Twig 函数 "is_expr_granted",它应该在 jms/security-extra-bundle 中。问题是 Twig 扩展(Twig/SecurityExtension) 似乎没有加载。有没有人经历过这个?有什么想法吗?

您需要在 jms/security-extra-bundle 中启用 expressions。添加 following/edit 您的 config.yml/security.yml 以保留以下内容:

jms_security_extra:
  expressions: true

启用表达式后,将加载 twig 扩展,从而加载 is_expr_granted