Is_granted method return error on Symfony 4

225 Views Asked by At

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?

1

There are 1 best solutions below

1
On BEST ANSWER

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