Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commitd8d53a7

Browse files
committed
Merge branch '5.3' into 5.4
* 5.3: [Security] Add PHP attributes to a PHP annotations example
2 parentscf8b67c +2ca63e5 commitd8d53a7

File tree

1 file changed

+46
-21
lines changed

1 file changed

+46
-21
lines changed

‎security.rst‎

Lines changed: 46 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2199,30 +2199,55 @@ will happen:
21992199
Thanks to the SensioFrameworkExtraBundle, you can also secure your controller
22002200
using annotations:
22012201

2202-
..code-block::diff
2202+
..configuration-block::
22032203

2204-
// src/Controller/AdminController.php
2205-
// ...
2204+
..code-block::php-annotations
22062205
2207-
+ use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
2206+
// src/Controller/AdminController.php
2207+
// ...
22082208
2209-
+ /**
2210-
+ * Require ROLE_ADMIN for *every* controller method in this class.
2211-
+ *
2212-
+ * @IsGranted("ROLE_ADMIN")
2213-
+ */
2214-
class AdminController extends AbstractController
2215-
{
2216-
+ /**
2217-
+ * Require ROLE_ADMIN for only this controller method.
2218-
+ *
2219-
+ * @IsGranted("ROLE_ADMIN")
2220-
+ */
2221-
public function adminDashboard(): Response
2222-
{
2223-
// ...
2224-
}
2225-
}
2209+
use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
2210+
2211+
/**
2212+
* Require ROLE_ADMIN for all the actions of this controller
2213+
*
2214+
* @IsGranted("ROLE_ADMIN")
2215+
*/
2216+
class AdminController extends AbstractController
2217+
{
2218+
/**
2219+
* Require ROLE_SUPER_ADMIN only for this action
2220+
*
2221+
* @IsGranted("ROLE_SUPER_ADMIN")
2222+
*/
2223+
public function adminDashboard(): Response
2224+
{
2225+
// ...
2226+
}
2227+
}
2228+
2229+
..code-block::php-attributes
2230+
2231+
// src/Controller/AdminController.php
2232+
// ...
2233+
2234+
use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
2235+
2236+
/**
2237+
* Require ROLE_ADMIN for all the actions of this controller
2238+
*/
2239+
#[IsGranted('ROLE_ADMIN')]
2240+
class AdminController extends AbstractController
2241+
{
2242+
/**
2243+
* Require ROLE_SUPER_ADMIN only for this action
2244+
*/
2245+
#[IsGranted('ROLE_SUPER_ADMIN')]
2246+
public function adminDashboard(): Response
2247+
{
2248+
// ...
2249+
}
2250+
}
22262251
22272252
For more information, see the `FrameworkExtraBundle documentation`_.
22282253

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp