@@ -898,11 +898,6 @@ UPGRADE FROM 2.x to 3.0
898
898
899
899
# ## Security
900
900
901
- * The `AbstractVoter` class was removed in favor of the new `Voter` class.
902
-
903
- * The `VoterInterface::supportsClass` and `supportsAttribute` methods were
904
- removed from the interface.
905
-
906
901
* The `Resources/` directory was moved to `Core/Resources/`
907
902
908
903
* The `key` settings of `anonymous`, `remember_me` and `http_digest` are
@@ -994,8 +989,15 @@ UPGRADE FROM 2.x to 3.0
994
989
));
995
990
` ` `
996
991
997
- * The `AbstractVoter::getSupportedAttributes()` and `AbstractVoter::getSupportedClasses()`
998
- methods have been removed in favor of `AbstractVoter::supports()`.
992
+ * The `AbstractVoter` class was removed. Instead, extend the new `Voter` class,
993
+ introduced in 2.8, and move your voting logic to the to the `supports($attribute, $subject)`
994
+ and `voteOnAttribute($attribute, $object, TokenInterface $token)` methods.
995
+
996
+ * The `vote()` method from the `VoterInterface` was changed to now accept arbitrary
997
+ types, and not only objects.
998
+
999
+ * The `supportsClass` and `supportsAttribute` methods were
1000
+ removed from the `VoterInterface` interface.
999
1001
1000
1002
Before :
1001
1003
@@ -1019,14 +1021,19 @@ UPGRADE FROM 2.x to 3.0
1019
1021
After :
1020
1022
1021
1023
` ` ` php
1022
- class MyVoter extends AbstractVoter
1024
+ use Symfony\C omponent\S ecurity\C ore\A uthorization\V oter\V oter;
1025
+
1026
+ class MyVoter extends Voter
1023
1027
{
1024
1028
protected function supports($attribute, $object)
1025
1029
{
1026
1030
return $object instanceof Post && in_array($attribute, array('CREATE', 'EDIT'));
1027
1031
}
1028
1032
1029
- // ...
1033
+ protected function voteOnAttribute($attribute, $object, TokenInterface $token)
1034
+ {
1035
+ // Return true or false
1036
+ }
1030
1037
}
1031
1038
` ` `
1032
1039
0 commit comments