@@ -12,7 +12,7 @@ which are like simple conditional statements.
12
12
.. seealso ::
13
13
14
14
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 `.
16
16
17
17
.. tip ::
18
18
@@ -25,13 +25,14 @@ How Symfony Uses Voters
25
25
26
26
In order to use voters, you have to understand how Symfony works with them.
27
27
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.
30
30
31
31
Ultimately, Symfony uses one of three different approaches on what to do
32
32
with the feedback from all voters: affirmative, consensus and unanimous.
33
33
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 >`.
35
36
36
37
The Voter Interface
37
38
-------------------
@@ -52,8 +53,8 @@ does not belong to this voter, it will return ``VoterInterface::ACCESS_ABSTAIN``
52
53
Creating the Custom Voter
53
54
-------------------------
54
55
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:
57
58
58
59
// src/Acme/DemoBundle/Security/Authorization/Voter/PostVoter.php
59
60
namespace Acme\D emoBundle\S ecurity\A uthorization\V oter;
@@ -93,8 +94,9 @@ view or edit a particular object. Here's an example implementation:
93
94
return VoterInterface::ACCESS_ABSTAIN;
94
95
}
95
96
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
98
100
if(1 !== count($attributes)) {
99
101
throw new InvalidArgumentException(
100
102
'Only one attribute is allowed for VIEW or EDIT'
0 commit comments