php - Symfony 4 上的 Is_granted 方法返回错误
问题描述
我正在学习 Symfony 4 并尝试在 twig 中使用 is_granted 方法,但不幸的是它返回错误:
HTTP 500 Internal Server Error
Argument 4 passed to Symfony\Component\Security\Core\Event\VoteEvent::__construct() must be of the type int, null given, called in /var/www/vendor/symfony/security-core/Authorization/Voter/TraceableVoter.php on line 41
这是我的代码
{% if is_granted('ROLE_USER') %}
{% endif %}
我对选民一无所知,但只想使用 is_granted 方法?这里有什么问题?
任何帮助将不胜感激?
解决方案
这里有一个类似的点:http: //github.com/symfony/symfony/issues/30675 A Voter 的vote()
方法没有 aa return
,它是用来创建一个VoteEvent
.
推荐阅读
- javascript - 如何仅将 XHR 请求发送到真实域?
- ios - 将 WebKit 会话传递给另一个视图控制器 Swift
- c - fgets() 导致分段错误
- python - pandas 多行到单行,2 个索引上有多列
- mysql - mysqlworkbench 中的这个查询有什么问题?
- javascript - 如何将 JavaScript 二维数组复制到剪贴板以将其粘贴到 excel 中?
- r - raster::erase 函数 - RGEOSBinTopoFunc 中的错误:TopologyException
- aws-lambda - Lambda,排序键添加导致失败
- python - 在 azure 中运行 python 脚本以从流 API 获取数据的选项
- c# - BitmapImage isDownloading 始终为真