diff options
author | Fabien Potencier <fabien.potencier@gmail.com> | 2013-09-04 17:17:08 +0200 |
---|---|---|
committer | Fabien Potencier <fabien.potencier@gmail.com> | 2013-09-19 12:59:11 +0200 |
commit | 7e74d3361617d93b258ebbee574657123f1d3e68 (patch) | |
tree | 75f143bf7cb05a25394443b73fc5b69736735c10 | |
parent | 842196b2dd50d94bc6ba982dc8cc10aa3d87964c (diff) | |
download | symfony-security-7e74d3361617d93b258ebbee574657123f1d3e68.zip symfony-security-7e74d3361617d93b258ebbee574657123f1d3e68.tar.gz symfony-security-7e74d3361617d93b258ebbee574657123f1d3e68.tar.bz2 |
mades things more consistent for the end user
-rw-r--r-- | Core/Authorization/Voter/ExpressionVoter.php | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/Core/Authorization/Voter/ExpressionVoter.php b/Core/Authorization/Voter/ExpressionVoter.php index bbe2e6b..50c8d5c 100644 --- a/Core/Authorization/Voter/ExpressionVoter.php +++ b/Core/Authorization/Voter/ExpressionVoter.php @@ -16,6 +16,7 @@ use Symfony\Component\Security\Core\Authentication\AuthenticationTrustResolverIn use Symfony\Component\Security\Core\Authorization\ExpressionLanguage; use Symfony\Component\Security\Core\Role\RoleHierarchyInterface; use Symfony\Component\ExpressionLanguage\Expression; +use Symfony\Component\HttpFoundation\Request; /** * ExpressionVoter votes based on the evaluation of an expression. @@ -75,6 +76,13 @@ class ExpressionVoter implements VoterInterface 'trust_resolver' => $this->trustResolver, ); + // this is mainly to propose a better experience when the expression is used + // in an access control rule, as the developer does not know that it's going + // to be handled by this voter + if ($object instanceof Request) { + $variables['request'] = $object; + } + $result = VoterInterface::ACCESS_ABSTAIN; foreach ($attributes as $attribute) { if (!$this->supportsAttribute($attribute)) { |