Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit cd5eb11

Browse files
committed
use is_granted() instead of deprecated has_role()
Deprecated in symfony/symfony#27305
1 parent 3235d06 commit cd5eb11

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

best_practices/security.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ Using ``@Security``, this looks like:
121121
* Displays a form to create a new Post entity.
122122
*
123123
* @Route("/new", name="admin_post_new")
124-
* @Security("has_role('ROLE_ADMIN')")
124+
* @Security("is_granted('ROLE_ADMIN')")
125125
*/
126126
public function new()
127127
{

security.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -892,7 +892,7 @@ using annotations::
892892
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
893893

894894
/**
895-
* @Security("has_role('ROLE_ADMIN')")
895+
* @Security("is_granted('ROLE_ADMIN')")
896896
*/
897897
public function hello($name)
898898
{

security/access_control.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ key:
265265
access_control:
266266
-
267267
path: ^/_internal/secure
268-
allow_if: "'127.0.0.1' == request.getClientIp() or has_role('ROLE_ADMIN')"
268+
allow_if: "'127.0.0.1' == request.getClientIp() or is_granted('ROLE_ADMIN')"
269269
270270
.. code-block:: xml
271271
@@ -279,7 +279,7 @@ key:
279279
280280
<config>
281281
<rule path="^/_internal/secure"
282-
allow-if="'127.0.0.1' == request.getClientIp() or has_role('ROLE_ADMIN')" />
282+
allow-if="'127.0.0.1' == request.getClientIp() or is_granted('ROLE_ADMIN')" />
283283
</config>
284284
</srv:container>
285285
@@ -288,7 +288,7 @@ key:
288288
'access_control' => array(
289289
array(
290290
'path' => '^/_internal/secure',
291-
'allow_if' => '"127.0.0.1" == request.getClientIp() or has_role("ROLE_ADMIN")',
291+
'allow_if' => '"127.0.0.1" == request.getClientIp() or is_granted("ROLE_ADMIN")',
292292
),
293293
),
294294

0 commit comments

Comments
 (0)