File tree Expand file tree Collapse file tree 2 files changed +13
-30
lines changed Expand file tree Collapse file tree 2 files changed +13
-30
lines changed Original file line number Diff line number Diff line change 1717use Symfony \Component \Security \Core \Role \RoleHierarchyInterface ;
1818use Symfony \Component \Validator \Validator \ValidatorInterface ;
1919use Symfony \Component \Workflow \Event \GuardEvent ;
20- use Symfony \Component \Workflow \Exception \InvalidTokenConfigurationException ;
2120use 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}
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments