Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit d3f9383

Browse filesBrowse files
committed
[symfony#3594] Nice tweaks thanks to @wouterj and @xabbuh
1 parent 2391758 commit d3f9383
Copy full SHA for d3f9383

File tree

Expand file treeCollapse file tree

1 file changed

+10
-8
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+10
-8
lines changed

‎cookbook/security/voters_data_permission.rst

Copy file name to clipboardExpand all lines: cookbook/security/voters_data_permission.rst
+10-8Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ which are like simple conditional statements.
1212
.. seealso::
1313

1414
Voters can also be used in other ways, like, for example, blacklisting IP
15-
addresses from the entire application: ":doc:`/cookbook/security/voters`".
15+
addresses from the entire application: :doc:`/cookbook/security/voters`.
1616

1717
.. tip::
1818

@@ -25,13 +25,14 @@ How Symfony Uses Voters
2525

2626
In order to use voters, you have to understand how Symfony works with them.
2727
All voters are called each time you use the ``isGranted()`` method on Symfony's
28-
security context (i.e. the ``security.context`` service). Each decides if
29-
the current user should have access to some resource.
28+
security context (i.e. the ``security.context`` service). Each one decides
29+
if the current user should have access to some resource.
3030

3131
Ultimately, Symfony uses one of three different approaches on what to do
3232
with the feedback from all voters: affirmative, consensus and unanimous.
3333

34-
For more information take a look at ":ref:`the section about access decision managers <components-security-access-decision-manager>`".
34+
For more information take a look at
35+
:ref:`the section about access decision managers <components-security-access-decision-manager>`.
3536

3637
The Voter Interface
3738
-------------------
@@ -52,8 +53,8 @@ does not belong to this voter, it will return ``VoterInterface::ACCESS_ABSTAIN``
5253
Creating the Custom Voter
5354
-------------------------
5455

55-
The goal is to create a voter that checks to see if a user has access to
56-
view or edit a particular object. Here's an example implementation:
56+
The goal is to create a voter that checks if a user has access to view or
57+
edit a particular object. Here's an example implementation:
5758

5859
// src/Acme/DemoBundle/Security/Authorization/Voter/PostVoter.php
5960
namespace Acme\DemoBundle\Security\Authorization\Voter;
@@ -93,8 +94,9 @@ view or edit a particular object. Here's an example implementation:
9394
return VoterInterface::ACCESS_ABSTAIN;
9495
}
9596
96-
// check if voter is used correct, only allow one attribute for a check
97-
// this isn't a requirement, it's just the way we want our voter to work
97+
// check if the voter is used correct, only allow one attribute
98+
// this isn't a requirement, it's just one easy way for you to
99+
// design your voter
98100
if(1 !== count($attributes)) {
99101
throw new InvalidArgumentException(
100102
'Only one attribute is allowed for VIEW or EDIT'

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.