Skip to content

Commit

Permalink
minor #5598 [Cookbook][Security] proofread comments in voter article …
Browse files Browse the repository at this point in the history
…(xabbuh)

This PR was merged into the 2.3 branch.

Discussion
----------

[Cookbook][Security] proofread comments in voter article

| Q             | A
| ------------- | ---
| Doc fix?      | yes
| New docs?     | no
| Applies to    | all
| Fixed tickets |

Commits
-------

4d1de98 proofread comments in voter article
  • Loading branch information
xabbuh committed Sep 5, 2015
2 parents de9f987 + 4d1de98 commit 05c57e3
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions cookbook/security/voters.rst
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,12 @@ edit a particular object. Here's an example implementation::
*/
public function vote(TokenInterface $token, $post, array $attributes)
{
// check if class of this object is supported by this voter
// check if the class of this object is supported by this voter
if (!$this->supportsClass(get_class($post))) {
return VoterInterface::ACCESS_ABSTAIN;
}

// check if the voter is used correct, only allow one attribute
// check if the voter is used correctly, only allow one attribute
// this isn't a requirement, it's just one easy way for you to
// design your voter
if (1 !== count($attributes)) {
Expand All @@ -134,9 +134,8 @@ edit a particular object. Here's an example implementation::
return VoterInterface::ACCESS_DENIED;
}

// double-check that the User object is the expected entity.
// It always will be, unless there is some misconfiguration of the
// security system.
// double-check that the User object is the expected entity (this
// only happens when you did not configure the security system properly)
if (!$user instanceof User) {
throw new \LogicException('The user is somehow not our User class!');
}
Expand Down Expand Up @@ -196,7 +195,8 @@ and tag it with ``security.voter``:
<services>
<service id="security.access.post_voter"
class="AppBundle\Security\Authorization\Voter\PostVoter"
public="false">
public="false"
>
<tag name="security.voter" />
</service>
Expand Down Expand Up @@ -238,7 +238,7 @@ from the security context is called.
// get a Post instance
$post = ...;
// keep in mind, this will call all registered security voters
// keep in mind that this will call all registered security voters
if (false === $this->get('security.context')->isGranted('view', $post)) {
throw new AccessDeniedException('Unauthorized access!');
}
Expand Down

0 comments on commit 05c57e3

Please sign in to comment.