bug #18934 Fixed some issues of the AccessDecisionManager profiler (javiereguiluz)
This PR was squashed before being merged into the 3.1 branch (closes #18934).
Discussion
----------
Fixed some issues of the AccessDecisionManager profiler
| Q | A
| ------------- | ---
| Branch? | 3.1
| Bug fix? | yes
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | #19022 https://github.com/symfony/symfony-standard/issues/968 https://github.com/schmittjoh/JMSSecurityExtraBundle/issues/207
| License | MIT
| Doc PR | -
Commits
-------
082f1b5
Fixed some issues of the AccessDecisionManager profiler
This commit is contained in:
commit
0b3b0d5268
@ -10,7 +10,7 @@
|
|||||||
<argument type="service" id="security.token_storage" on-invalid="ignore" />
|
<argument type="service" id="security.token_storage" on-invalid="ignore" />
|
||||||
<argument type="service" id="security.role_hierarchy" />
|
<argument type="service" id="security.role_hierarchy" />
|
||||||
<argument type="service" id="security.logout_url_generator" />
|
<argument type="service" id="security.logout_url_generator" />
|
||||||
<argument type="service" id="debug.security.access.decision_manager" />
|
<argument type="service" id="security.access.decision_manager" />
|
||||||
</service>
|
</service>
|
||||||
</services>
|
</services>
|
||||||
</container>
|
</container>
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
<?xml version="1.0" ?>
|
<?xml version="1.0" ?>
|
||||||
|
|
||||||
<container xmlns="http://symfony.com/schema/dic/services"
|
<container xmlns="http://symfony.com/schema/dic/services"
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
|
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
|
||||||
|
|
||||||
<services>
|
<services>
|
||||||
<service id="debug.security.access.decision_manager" class="Symfony\Component\Security\Core\Authorization\DebugAccessDecisionManager" decorates="security.access.decision_manager" public="false">
|
<service id="debug.security.access.decision_manager" class="Symfony\Component\Security\Core\Authorization\DebugAccessDecisionManager" decorates="security.access.decision_manager" public="false">
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
],
|
],
|
||||||
"require": {
|
"require": {
|
||||||
"php": ">=5.5.9",
|
"php": ">=5.5.9",
|
||||||
"symfony/security": "~3.1",
|
"symfony/security": "~3.1,>=3.1.2",
|
||||||
"symfony/http-kernel": "~2.8|~3.0",
|
"symfony/http-kernel": "~2.8|~3.0",
|
||||||
"symfony/polyfill-php70": "~1.0"
|
"symfony/polyfill-php70": "~1.0"
|
||||||
},
|
},
|
||||||
|
@ -26,17 +26,19 @@ class DebugAccessDecisionManager implements AccessDecisionManagerInterface
|
|||||||
{
|
{
|
||||||
private $manager;
|
private $manager;
|
||||||
private $strategy;
|
private $strategy;
|
||||||
private $voters;
|
private $voters = array();
|
||||||
private $decisionLog = array();
|
private $decisionLog = array();
|
||||||
|
|
||||||
public function __construct(AccessDecisionManager $manager)
|
public function __construct(AccessDecisionManagerInterface $manager)
|
||||||
{
|
{
|
||||||
$this->manager = $manager;
|
$this->manager = $manager;
|
||||||
|
|
||||||
// The strategy is stored in a private property of the decorated service
|
if ($this->manager instanceof AccessDecisionManager) {
|
||||||
$reflection = new \ReflectionProperty($manager, 'strategy');
|
// The strategy is stored in a private property of the decorated service
|
||||||
$reflection->setAccessible(true);
|
$reflection = new \ReflectionProperty(AccessDecisionManager::class, 'strategy');
|
||||||
$this->strategy = $reflection->getValue($manager);
|
$reflection->setAccessible(true);
|
||||||
|
$this->strategy = $reflection->getValue($manager);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -60,6 +62,10 @@ class DebugAccessDecisionManager implements AccessDecisionManagerInterface
|
|||||||
*/
|
*/
|
||||||
public function setVoters(array $voters)
|
public function setVoters(array $voters)
|
||||||
{
|
{
|
||||||
|
if (!$this->manager instanceof AccessDecisionManager) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$this->voters = $voters;
|
$this->voters = $voters;
|
||||||
$this->manager->setVoters($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
|
// The $strategy property is misleading because it stores the name of its
|
||||||
// method (e.g. 'decideAffirmative') instead of the original strategy name
|
// method (e.g. 'decideAffirmative') instead of the original strategy name
|
||||||
// (e.g. 'affirmative')
|
// (e.g. 'affirmative')
|
||||||
return strtolower(substr($this->strategy, 6));
|
return null === $this->strategy ? '-' : strtolower(substr($this->strategy, 6));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user