Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Cookbook][Security] proofread comments in voter article #5598

Merged
merged 1 commit into from
Sep 5, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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