简体   繁体   中英

Is_granted method return error on Symfony 4

I am learning Symfony 4 and trying to use is_granted method in twig but unfortunately it return errors:

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

Here is my code

{% if is_granted('ROLE_USER') %}
{% endif %}

I have no knowledge with voter yet but want to use is_granted method only? what is the problem here?

Any help would be extremely appreciated?

There is a similar point here: http://github.com/symfony/symfony/issues/30675 A Voter's vote() method did not have aa return , which is used to create a VoteEvent .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM