summaryrefslogtreecommitdiffstats
path: root/Core/Authorization/DebugAccessDecisionManager.php
diff options
context:
space:
mode:
Diffstat (limited to 'Core/Authorization/DebugAccessDecisionManager.php')
-rw-r--r--Core/Authorization/DebugAccessDecisionManager.php20
1 files changed, 13 insertions, 7 deletions
diff --git a/Core/Authorization/DebugAccessDecisionManager.php b/Core/Authorization/DebugAccessDecisionManager.php
index 540d998..1a04bc1 100644
--- a/Core/Authorization/DebugAccessDecisionManager.php
+++ b/Core/Authorization/DebugAccessDecisionManager.php
@@ -26,17 +26,19 @@ class DebugAccessDecisionManager implements AccessDecisionManagerInterface
{
private $manager;
private $strategy;
- private $voters;
+ private $voters = array();
private $decisionLog = array();
- public function __construct(AccessDecisionManager $manager)
+ public function __construct(AccessDecisionManagerInterface $manager)
{
$this->manager = $manager;
- // The strategy is stored in a private property of the decorated service
- $reflection = new \ReflectionProperty($manager, 'strategy');
- $reflection->setAccessible(true);
- $this->strategy = $reflection->getValue($manager);
+ if ($this->manager instanceof AccessDecisionManager) {
+ // The strategy is stored in a private property of the decorated service
+ $reflection = new \ReflectionProperty(AccessDecisionManager::class, 'strategy');
+ $reflection->setAccessible(true);
+ $this->strategy = $reflection->getValue($manager);
+ }
}
/**
@@ -60,6 +62,10 @@ class DebugAccessDecisionManager implements AccessDecisionManagerInterface
*/
public function setVoters(array $voters)
{
+ if (!$this->manager instanceof AccessDecisionManager) {
+ return;
+ }
+
$this->voters = $voters;
$this->manager->setVoters($voters);
}
@@ -72,7 +78,7 @@ class DebugAccessDecisionManager implements AccessDecisionManagerInterface
// The $strategy property is misleading because it stores the name of its
// method (e.g. 'decideAffirmative') instead of the original strategy name
// (e.g. 'affirmative')
- return strtolower(substr($this->strategy, 6));
+ return null === $this->strategy ? '-' : strtolower(substr($this->strategy, 6));
}
/**