summaryrefslogtreecommitdiffstats
path: root/Core/Authorization
diff options
context:
space:
mode:
authorKonstantin.Myakshin <koc-dp@yandex.ru>2015-10-04 12:03:28 +0300
committerKonstantin.Myakshin <koc-dp@yandex.ru>2015-10-04 12:08:57 +0300
commit6a830f8b84ab0f22c06c090297bd8f45e24e8be4 (patch)
treeb8d89ad1bf20d9a15a6e77b21656546e3df6002b /Core/Authorization
parent0d3da2a02c2ebabb1e6a4ce898308c1989963185 (diff)
downloadsymfony-security-6a830f8b84ab0f22c06c090297bd8f45e24e8be4.zip
symfony-security-6a830f8b84ab0f22c06c090297bd8f45e24e8be4.tar.gz
symfony-security-6a830f8b84ab0f22c06c090297bd8f45e24e8be4.tar.bz2
Simplify AbstractVoter
Diffstat (limited to 'Core/Authorization')
-rw-r--r--Core/Authorization/Voter/AbstractVoter.php30
1 files changed, 6 insertions, 24 deletions
diff --git a/Core/Authorization/Voter/AbstractVoter.php b/Core/Authorization/Voter/AbstractVoter.php
index 12b54db..24060c0 100644
--- a/Core/Authorization/Voter/AbstractVoter.php
+++ b/Core/Authorization/Voter/AbstractVoter.php
@@ -68,10 +68,9 @@ abstract class AbstractVoter implements VoterInterface
// abstain vote by default in case none of the attributes are supported
$vote = self::ACCESS_ABSTAIN;
- $class = get_class($object);
foreach ($attributes as $attribute) {
- if (!$this->supports($attribute, $class)) {
+ if (!$this->supports($attribute, $object)) {
continue;
}
@@ -88,25 +87,22 @@ abstract class AbstractVoter implements VoterInterface
}
/**
- * Determines if the attribute and class are supported by this voter.
- *
- * To determine if the passed class is instance of the supported class, the
- * isClassInstanceOf() method can be used.
+ * Determines if the attribute and object are supported by this voter.
*
* This method will become abstract in 3.0.
*
* @param string $attribute An attribute
- * @param string $class The fully qualified class name of the passed object
+ * @param string $object The object to secure
*
- * @return bool True if the attribute and class is supported, false otherwise
+ * @return bool True if the attribute and object is supported, false otherwise
*/
- protected function supports($attribute, $class)
+ protected function supports($attribute, $object)
{
@trigger_error('The getSupportedClasses and getSupportedAttributes methods are deprecated since version 2.8 and will be removed in version 3.0. Overwrite supports instead.', E_USER_DEPRECATED);
$classIsSupported = false;
foreach ($this->getSupportedClasses() as $supportedClass) {
- if ($this->isClassInstanceOf($class, $supportedClass)) {
+ if ($object instanceof $supportedClass) {
$classIsSupported = true;
break;
}
@@ -124,20 +120,6 @@ abstract class AbstractVoter implements VoterInterface
}
/**
- * A helper method to test if the actual class is instanceof or equal
- * to the expected class.
- *
- * @param string $actualClass The actual class name
- * @param string $expectedClass The expected class name
- *
- * @return bool
- */
- protected function isClassInstanceOf($actualClass, $expectedClass)
- {
- return $expectedClass === $actualClass || is_subclass_of($actualClass, $expectedClass);
- }
-
- /**
* Return an array of supported classes. This will be called by supportsClass.
*
* @return array an array of supported classes, i.e. array('Acme\DemoBundle\Model\Product')