Skip to content

Commit 195ff25

Browse files
committed
Merge branch '5.0' into 5.1
* 5.0: Update firewall.rst Update voters.rst Update authorization.rst Update authorization.rst
2 parents 49455bb + 79d3968 commit 195ff25

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

components/security/authorization.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ RoleVoter
142142
The :class:`Symfony\\Component\\Security\\Core\\Authorization\\Voter\\RoleVoter`
143143
supports attributes starting with ``ROLE_`` and grants access to the user
144144
when at least one required ``ROLE_*`` attribute can be found in the array of
145-
roles returned by the token's :method:`Symfony\\Component\\Security\\Core\\Authentication\\Token\\TokenInterface::getRoles`
145+
roles returned by the token's :method:`Symfony\\Component\\Security\\Core\\Authentication\\Token\\TokenInterface::getRoleNames`
146146
method::
147147

148148
use Symfony\Component\Security\Core\Authorization\Voter\RoleVoter;
@@ -204,7 +204,7 @@ expressions have access to a number of
204204
$object = ...;
205205

206206
$expression = new Expression(
207-
'"ROLE_ADMIN" in roles or (not is_anonymous() and user.isSuperAdmin())'
207+
'"ROLE_ADMIN" in role_names or (not is_anonymous() and user.isSuperAdmin())'
208208
)
209209

210210
$vote = $expressionVoter->vote($token, $object, [$expression]);

components/security/firewall.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ entry point and access denied URL, is provided by instances of the
9696
:class:`Symfony\\Bundle\\SecurityBundle\\Security\\FirewallConfig` class.
9797

9898
This object can be accessed through the ``getFirewallConfig(Request $request)``
99-
method of the :class:`Symfony\\Component\\Security\\Http\\FirewallMap` class and
99+
method of the :class:`Symfony\\Bundle\\SecurityBundle\\Security\\FirewallMap` class and
100100
through the ``getConfig()`` method of the
101101
:class:`Symfony\\Bundle\\SecurityBundle\\Security\\FirewallContext` class.
102102

security/voters.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ would look like this::
118118
const VIEW = 'view';
119119
const EDIT = 'edit';
120120

121-
protected function supports($attribute, $subject)
121+
protected function supports(string $attribute, $subject)
122122
{
123123
// if the attribute isn't one we support, return false
124124
if (!in_array($attribute, [self::VIEW, self::EDIT])) {
@@ -133,7 +133,7 @@ would look like this::
133133
return true;
134134
}
135135

136-
protected function voteOnAttribute($attribute, $subject, TokenInterface $token)
136+
protected function voteOnAttribute(string $attribute, $subject, TokenInterface $token)
137137
{
138138
$user = $token->getUser();
139139

@@ -178,7 +178,7 @@ That's it! The voter is done! Next, :ref:`configure it <declaring-the-voter-as-a
178178

179179
To recap, here's what's expected from the two abstract methods:
180180

181-
``Voter::supports($attribute, $subject)``
181+
``Voter::supports(string $attribute, $subject)``
182182
When ``isGranted()`` (or ``denyAccessUnlessGranted()``) is called, the first
183183
argument is passed here as ``$attribute`` (e.g. ``ROLE_USER``, ``edit``) and
184184
the second argument (if any) is passed as ``$subject`` (e.g. ``null``, a ``Post``
@@ -188,7 +188,7 @@ To recap, here's what's expected from the two abstract methods:
188188
return ``true`` if the attribute is ``view`` or ``edit`` and if the object is
189189
a ``Post`` instance.
190190

191-
``voteOnAttribute($attribute, $subject, TokenInterface $token)``
191+
``voteOnAttribute(string $attribute, $subject, TokenInterface $token)``
192192
If you return ``true`` from ``supports()``, then this method is called. Your
193193
job is simple: return ``true`` to allow access and ``false`` to deny access.
194194
The ``$token`` can be used to find the current user object (if any). In this
@@ -231,7 +231,7 @@ with ``ROLE_SUPER_ADMIN``::
231231
$this->security = $security;
232232
}
233233

234-
protected function voteOnAttribute($attribute, $subject, TokenInterface $token)
234+
protected function voteOnAttribute(string $attribute, $subject, TokenInterface $token)
235235
{
236236
// ...
237237

0 commit comments

Comments
 (0)