File tree 2 files changed +13
-30
lines changed
src/Symfony/Component/Workflow
2 files changed +13
-30
lines changed Original file line number Diff line number Diff line change 17
17
use Symfony \Component \Security \Core \Role \RoleHierarchyInterface ;
18
18
use Symfony \Component \Validator \Validator \ValidatorInterface ;
19
19
use Symfony \Component \Workflow \Event \GuardEvent ;
20
- use Symfony \Component \Workflow \Exception \InvalidTokenConfigurationException ;
21
20
use Symfony \Component \Workflow \TransitionBlocker ;
22
21
23
22
/**
@@ -76,15 +75,8 @@ private function getVariables(GuardEvent $event): array
76
75
{
77
76
$ token = $ this ->tokenStorage ->getToken ();
78
77
79
- if (null === $ token ) {
80
- throw new InvalidTokenConfigurationException (sprintf ('There are no tokens available for workflow "%s". ' , $ event ->getWorkflowName ()));
81
- }
82
-
83
78
$ variables = [
84
- 'token ' => $ token ,
85
- 'user ' => $ token ->getUser (),
86
79
'subject ' => $ event ->getSubject (),
87
- 'role_names ' => $ this ->roleHierarchy ->getReachableRoleNames ($ token ->getRoleNames ()),
88
80
// needed for the is_granted expression function
89
81
'auth_checker ' => $ this ->authorizationChecker ,
90
82
// needed for the is_* expression function
@@ -93,6 +85,18 @@ private function getVariables(GuardEvent $event): array
93
85
'validator ' => $ this ->validator ,
94
86
];
95
87
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
+ ];
97
101
}
98
102
}
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments