Skip to content

Commit

Permalink
minor symfony#17507 Update UPGRADE-3.0 with correct Voter details (jb…
Browse files Browse the repository at this point in the history
…afford)

This PR was merged into the 2.8 branch.

Discussion
----------

Update UPGRADE-3.0 with correct Voter details

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | n/a
| Fixed tickets |
| License       | MIT
| Doc PR        |

AbstractVoter was removed, but the upgrade instructions to use Voter were not complete and continued to reference AbstractVoter.

Commits
-------

7b2a538 Update UPGRADE-3.0 with correct Voter details
  • Loading branch information
fabpot committed Jan 27, 2016
2 parents 5d3d913 + 7b2a538 commit 5f5f4aa
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions UPGRADE-3.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -898,11 +898,6 @@ UPGRADE FROM 2.x to 3.0

### Security

* The `AbstractVoter` class was removed in favor of the new `Voter` class.

* The `VoterInterface::supportsClass` and `supportsAttribute` methods were
removed from the interface.

* The `Resources/` directory was moved to `Core/Resources/`

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

* The `AbstractVoter::getSupportedAttributes()` and `AbstractVoter::getSupportedClasses()`
methods have been removed in favor of `AbstractVoter::supports()`.
* The `AbstractVoter` class was removed. Instead, extend the new `Voter` class,
introduced in 2.8, and move your voting logic to the to the `supports($attribute, $subject)`
and `voteOnAttribute($attribute, $object, TokenInterface $token)` methods.

* The `vote()` method from the `VoterInterface` was changed to now accept arbitrary
types, and not only objects.

* The `supportsClass` and `supportsAttribute` methods were
removed from the `VoterInterface` interface.

Before:

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

```php
class MyVoter extends AbstractVoter
use Symfony\Component\Security\Core\Authorization\Voter\Voter;
class MyVoter extends Voter
{
protected function supports($attribute, $object)
{
return $object instanceof Post && in_array($attribute, array('CREATE', 'EDIT'));
}
// ...
protected function voteOnAttribute($attribute, $object, TokenInterface $token)
{
// Return true or false
}
}
```

Expand Down

0 comments on commit 5f5f4aa

Please sign in to comment.