Skip to content

Commit 7b2a538

Browse files
committed
Update UPGRADE-3.0 with correct Voter details
AbstractVoter was removed, but the upgrade instructions to use Voter were not complete and continued to reference AbstractVoter.
1 parent 295f5ee commit 7b2a538

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

UPGRADE-3.0.md

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -898,11 +898,6 @@ UPGRADE FROM 2.x to 3.0
898898

899899
### Security
900900

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-
906901
* The `Resources/` directory was moved to `Core/Resources/`
907902

908903
* The `key` settings of `anonymous`, `remember_me` and `http_digest` are
@@ -994,8 +989,15 @@ UPGRADE FROM 2.x to 3.0
994989
));
995990
```
996991

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.
9991001

10001002
Before:
10011003

@@ -1019,14 +1021,19 @@ UPGRADE FROM 2.x to 3.0
10191021
After:
10201022

10211023
```php
1022-
class MyVoter extends AbstractVoter
1024+
use Symfony\Component\Security\Core\Authorization\Voter\Voter;
1025+
1026+
class MyVoter extends Voter
10231027
{
10241028
protected function supports($attribute, $object)
10251029
{
10261030
return $object instanceof Post && in_array($attribute, array('CREATE', 'EDIT'));
10271031
}
10281032
1029-
// ...
1033+
protected function voteOnAttribute($attribute, $object, TokenInterface $token)
1034+
{
1035+
// Return true or false
1036+
}
10301037
}
10311038
```
10321039

0 commit comments

Comments
 (0)