summaryrefslogtreecommitdiffstats
path: root/Core
diff options
context:
space:
mode:
Diffstat (limited to 'Core')
-rw-r--r--Core/Authorization/Voter/AbstractVoter.php31
-rw-r--r--Core/Tests/Authorization/Voter/AbstractVoterTest.php54
2 files changed, 1 insertions, 84 deletions
diff --git a/Core/Authorization/Voter/AbstractVoter.php b/Core/Authorization/Voter/AbstractVoter.php
index 489c68d..ee73d29 100644
--- a/Core/Authorization/Voter/AbstractVoter.php
+++ b/Core/Authorization/Voter/AbstractVoter.php
@@ -95,40 +95,11 @@ abstract class AbstractVoter implements VoterInterface
* a UserInterface object (fully authenticated user)
* a string (anonymously authenticated user).
*
- * @param string $attribute
- * @param object $object
- * @param UserInterface|string $user
- *
- * @deprecated This method will be removed in 3.0 - override voteOnAttribute instead.
- *
- * @return bool
- */
- protected function isGranted($attribute, $object, $user = null)
- {
- // forces isGranted() or voteOnAttribute() to be overridden
- throw new \BadMethodCallException(sprintf('You must override the voteOnAttribute() method in "%s".', get_class($this)));
- }
-
- /**
- * Perform a single access check operation on a given attribute, object and (optionally) user
- * It is safe to assume that $attribute and $object's class pass supportsAttribute/supportsClass
- * $user can be one of the following:
- * a UserInterface object (fully authenticated user)
- * a string (anonymously authenticated user).
- *
- * This method will become abstract in 3.0.
- *
* @param string $attribute
* @param object $object
* @param TokenInterface $token
*
* @return bool
*/
- protected function voteOnAttribute($attribute, $object, TokenInterface $token)
- {
- // the user should override this method, and not rely on the deprecated isGranted()
- @trigger_error(sprintf("The AbstractVoter::isGranted() method is deprecated since 2.8 and won't be called anymore in 3.0. Override voteOnAttribute() in %s instead.", get_class($this)), E_USER_DEPRECATED);
-
- return $this->isGranted($attribute, $object, $token->getUser());
- }
+ abstract protected function voteOnAttribute($attribute, $object, TokenInterface $token);
}
diff --git a/Core/Tests/Authorization/Voter/AbstractVoterTest.php b/Core/Tests/Authorization/Voter/AbstractVoterTest.php
index 7062d39..aafef5a 100644
--- a/Core/Tests/Authorization/Voter/AbstractVoterTest.php
+++ b/Core/Tests/Authorization/Voter/AbstractVoterTest.php
@@ -54,27 +54,6 @@ class AbstractVoterTest extends \PHPUnit_Framework_TestCase
$this->assertEquals($expectedVote, $voter->vote($this->token, $object, $attributes), $message);
}
-
- /**
- * @dataProvider getTests
- * @group legacy
- */
- public function testVoteLegacy(array $attributes, $expectedVote, $object, $message)
- {
- $voter = new AbstractVoterTest_LegacyVoter();
-
- $this->assertEquals($expectedVote, $voter->vote($this->token, $object, $attributes), $message);
- }
-
- /**
- * @group legacy
- * @expectedException \BadMethodCallException
- */
- public function testNoOverriddenMethodsThrowsException()
- {
- $voter = new AbstractVoterTest_NothingImplementedVoter();
- $voter->vote($this->token, new \stdClass(), array('EDIT'));
- }
}
class AbstractVoterTest_Voter extends AbstractVoter
@@ -90,36 +69,3 @@ class AbstractVoterTest_Voter extends AbstractVoter
&& in_array($attribute, array('EDIT', 'CREATE'));
}
}
-
-class AbstractVoterTest_LegacyVoter extends AbstractVoter
-{
- protected function getSupportedClasses()
- {
- return array('stdClass');
- }
-
- protected function getSupportedAttributes()
- {
- return array('EDIT', 'CREATE');
- }
-
- protected function isGranted($attribute, $object, $user = null)
- {
- return 'EDIT' === $attribute;
- }
-}
-
-class AbstractVoterTest_NothingImplementedVoter extends AbstractVoter
-{
- protected function getSupportedClasses()
- {
- return array('stdClass');
- }
-
- protected function getSupportedAttributes()
- {
- return array('EDIT', 'CREATE');
- }
-
- // this is a bad voter that hasn't overridden isGranted or voteOnAttribute
-}