@@ -26,17 +26,19 @@ class DebugAccessDecisionManager implements AccessDecisionManagerInterface
26
26
{
27
27
private $ manager ;
28
28
private $ strategy ;
29
- private $ voters ;
29
+ private $ voters = array () ;
30
30
private $ decisionLog = array ();
31
31
32
- public function __construct (AccessDecisionManager $ manager )
32
+ public function __construct (AccessDecisionManagerInterface $ manager )
33
33
{
34
34
$ this ->manager = $ manager ;
35
35
36
- // The strategy is stored in a private property of the decorated service
37
- $ reflection = new \ReflectionProperty ($ manager , 'strategy ' );
38
- $ reflection ->setAccessible (true );
39
- $ this ->strategy = $ reflection ->getValue ($ manager );
36
+ if ($ this ->manager instanceof AccessDecisionManager) {
37
+ // The strategy is stored in a private property of the decorated service
38
+ $ reflection = new \ReflectionProperty (AccessDecisionManager::class, 'strategy ' );
39
+ $ reflection ->setAccessible (true );
40
+ $ this ->strategy = $ reflection ->getValue ($ manager );
41
+ }
40
42
}
41
43
42
44
/**
@@ -60,6 +62,10 @@ public function decide(TokenInterface $token, array $attributes, $object = null)
60
62
*/
61
63
public function setVoters (array $ voters )
62
64
{
65
+ if (!$ this ->manager instanceof AccessDecisionManager) {
66
+ return ;
67
+ }
68
+
63
69
$ this ->voters = $ voters ;
64
70
$ this ->manager ->setVoters ($ voters );
65
71
}
@@ -72,7 +78,7 @@ public function getStrategy()
72
78
// The $strategy property is misleading because it stores the name of its
73
79
// method (e.g. 'decideAffirmative') instead of the original strategy name
74
80
// (e.g. 'affirmative')
75
- return strtolower (substr ($ this ->strategy , 6 ));
81
+ return null === $ this -> strategy ? ' - ' : strtolower (substr ($ this ->strategy , 6 ));
76
82
}
77
83
78
84
/**
0 commit comments