Skip to content

Commit d0c035d

Browse files
authored
Prevent error when session is not set
Prevent error when session is not set (E.G when running from the cli and no request is set)
1 parent 59e2c17 commit d0c035d

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

src/Symfony/Toggle.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,13 @@ public function isActive(string $feature, array $context = []): bool
9090
: $this->roleHierarchy->getReachableRoleNames($rolesArray);
9191
}
9292

93+
$request = $this->requestStack->getCurrentRequest();
94+
9395
self::$variables = [
9496
'token' => $token,
95-
'request' => $this->requestStack->getCurrentRequest(),
97+
'request' => $request,
9698
'roles' => $roles,
97-
'session' => $this->requestStack->getCurrentRequest()->getSession(),
99+
'session' => $request ? $request->getSession() : $request,
98100
'trust_resolver' => $this->trustResolver,
99101
'auth_checker' => $this->authorizationChecker,
100102
'user' => null !== $token ? $token->getUser() : null,

0 commit comments

Comments
 (0)