Skip to content

Commit

Permalink
Prevent error when session is not set
Browse files Browse the repository at this point in the history
Prevent error when session is not set (E.G when running from the cli and no request is set)
  • Loading branch information
pierredup authored Nov 12, 2024
1 parent 59e2c17 commit d0c035d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/Symfony/Toggle.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,13 @@ public function isActive(string $feature, array $context = []): bool
: $this->roleHierarchy->getReachableRoleNames($rolesArray);
}

$request = $this->requestStack->getCurrentRequest();

self::$variables = [
'token' => $token,
'request' => $this->requestStack->getCurrentRequest(),
'request' => $request,
'roles' => $roles,
'session' => $this->requestStack->getCurrentRequest()->getSession(),
'session' => $request ? $request->getSession() : $request,
'trust_resolver' => $this->trustResolver,
'auth_checker' => $this->authorizationChecker,
'user' => null !== $token ? $token->getUser() : null,
Expand Down

0 comments on commit d0c035d

Please sign in to comment.