0

我正在学习 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 方法?这里有什么问题?

任何帮助将不胜感激?

4

1 回答 1

2

这里有一个类似的点:http: //github.com/symfony/symfony/issues/30675 A Voter 的vote()方法没有 aa return,它是用来创建一个VoteEvent.

于 2019-10-12T15:02:26.830 回答