createBlockedByExpressionGuardListener example


                $this->validateGuardExpression($event$guard->getExpression());
            } else {
                $this->validateGuardExpression($event$guard);
            }
        }
    }

    private function validateGuardExpression(GuardEvent $event, string $expression): void
    {
        if (!$this->expressionLanguage->evaluate($expression$this->getVariables($event))) {
            $blocker = TransitionBlocker::createBlockedByExpressionGuardListener($expression);
            $event->addTransitionBlocker($blocker);
        }
    }

    // code should be sync with Symfony\Component\Security\Core\Authorization\Voter\ExpressionVoter     private function getVariables(GuardEvent $event): array
    {
        $token = $this->tokenStorage->getToken();

        $variables = [
            'subject' => $event->getSubject(),
            
Home | Imprint | This part of the site doesn't use cookies.