summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFabien Potencier <fabien.potencier@gmail.com>2011-01-07 17:14:20 +0100
committerFabien Potencier <fabien.potencier@gmail.com>2011-01-07 17:14:41 +0100
commitb63e571ba8edb2c24ceb9bcc3c3336e34d8ac4a7 (patch)
treec2ceab6b921c142b31c2e52025f013f89791ed9d
parent86809681ed8cf47ec8377226865cc37caf45fe84 (diff)
downloadsymfony-security-b63e571ba8edb2c24ceb9bcc3c3336e34d8ac4a7.zip
symfony-security-b63e571ba8edb2c24ceb9bcc3c3336e34d8ac4a7.tar.gz
symfony-security-b63e571ba8edb2c24ceb9bcc3c3336e34d8ac4a7.tar.bz2
removed duplicate code
-rw-r--r--SecurityContext.php11
1 files changed, 10 insertions, 1 deletions
diff --git a/SecurityContext.php b/SecurityContext.php
index ff0df08..8efc950 100644
--- a/SecurityContext.php
+++ b/SecurityContext.php
@@ -4,6 +4,7 @@ namespace Symfony\Component\Security;
use Symfony\Component\Security\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Authorization\AccessDecisionManager;
+use Symfony\Component\Security\Acl\Voter\FieldVote;
/*
* This file is part of the Symfony package.
@@ -45,12 +46,20 @@ class SecurityContext
return null === $this->token ? null : $this->token->getUser();
}
- public function vote($attributes, $object = null)
+ public function vote($attributes, $object = null, $field = null)
{
if (null === $this->token || null === $this->accessDecisionManager) {
return false;
}
+ if ($field !== null) {
+ if (null === $object) {
+ throw new \InvalidArgumentException('$object cannot be null when field is not null.');
+ }
+
+ $object = new FieldVote($object, $field);
+ }
+
return $this->accessDecisionManager->decide($this->token, (array) $attributes, $object);
}