Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit bd26a79

Browse filesBrowse files
committed
[Worflow] Fixed GuardListener when using the new Security system
1 parent b128423 commit bd26a79
Copy full SHA for bd26a79

File tree

2 files changed

+13
-30
lines changed
Filter options

2 files changed

+13
-30
lines changed

‎src/Symfony/Component/Workflow/EventListener/GuardListener.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Workflow/EventListener/GuardListener.php
+13-9Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
use Symfony\Component\Security\Core\Role\RoleHierarchyInterface;
1818
use Symfony\Component\Validator\Validator\ValidatorInterface;
1919
use Symfony\Component\Workflow\Event\GuardEvent;
20-
use Symfony\Component\Workflow\Exception\InvalidTokenConfigurationException;
2120
use Symfony\Component\Workflow\TransitionBlocker;
2221

2322
/**
@@ -76,15 +75,8 @@ private function getVariables(GuardEvent $event): array
7675
{
7776
$token = $this->tokenStorage->getToken();
7877

79-
if (null === $token) {
80-
throw new InvalidTokenConfigurationException(sprintf('There are no tokens available for workflow "%s".', $event->getWorkflowName()));
81-
}
82-
8378
$variables = [
84-
'token' => $token,
85-
'user' => $token->getUser(),
8679
'subject' => $event->getSubject(),
87-
'role_names' => $this->roleHierarchy->getReachableRoleNames($token->getRoleNames()),
8880
// needed for the is_granted expression function
8981
'auth_checker' => $this->authorizationChecker,
9082
// needed for the is_* expression function
@@ -93,6 +85,18 @@ private function getVariables(GuardEvent $event): array
9385
'validator' => $this->validator,
9486
];
9587

96-
return $variables;
88+
if (null === $token) {
89+
return $variables + [
90+
'token' => null,
91+
'user' => null,
92+
'role_names' => [],
93+
];
94+
}
95+
96+
return $variables + [
97+
'token' => $token,
98+
'user' => $token->getUser(),
99+
'role_names' => $this->roleHierarchy->getReachableRoleNames($token->getRoleNames()),
100+
];
97101
}
98102
}

‎src/Symfony/Component/Workflow/Exception/InvalidTokenConfigurationException.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Workflow/Exception/InvalidTokenConfigurationException.php
-21Lines changed: 0 additions & 21 deletions
This file was deleted.

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.