|
14 | 14 | use Symfony\Component\ExpressionLanguage\Expression;
|
15 | 15 |
|
16 | 16 | /**
|
| 17 | + * Checks if user has permission to access to some resource using security roles and voters. |
| 18 | + * |
| 19 | + * @see https://symfony.com/doc/current/security.html#roles |
| 20 | + * |
17 | 21 | * @author Ryan Weaver <[email protected]>
|
18 | 22 | */
|
19 | 23 | #[\Attribute(\Attribute::IS_REPEATABLE | \Attribute::TARGET_CLASS | \Attribute::TARGET_METHOD | \Attribute::TARGET_FUNCTION)]
|
20 | 24 | final class IsGranted
|
21 | 25 | {
|
| 26 | + /** |
| 27 | + * @param string|Expression $attribute The attribute that will be checked against a given authentication token and optional subject |
| 28 | + * @param array|string|Expression|null $subject An optional subject - e.g. the current object being voted on |
| 29 | + * @param string|null $message A custom message when access is not granted |
| 30 | + * @param int|null $statusCode If set, will throw HttpKernel's HttpException with the given $statusCode; if null, Security\Core's AccessDeniedException will be used |
| 31 | + * @param int|null $exceptionCode If set, will add the exception code to thrown exception |
| 32 | + */ |
22 | 33 | public function __construct(
|
23 |
| - /** |
24 |
| - * Sets the first argument that will be passed to isGranted(). |
25 |
| - */ |
26 | 34 | public string|Expression $attribute,
|
27 |
| - |
28 |
| - /** |
29 |
| - * Sets the second argument passed to isGranted(). |
30 |
| - * |
31 |
| - * @var array<string|Expression>|string|Expression|null |
32 |
| - */ |
33 | 35 | public array|string|Expression|null $subject = null,
|
34 |
| - |
35 |
| - /** |
36 |
| - * The message of the exception - has a nice default if not set. |
37 |
| - */ |
38 | 36 | public ?string $message = null,
|
39 |
| - |
40 |
| - /** |
41 |
| - * If set, will throw HttpKernel's HttpException with the given $statusCode. |
42 |
| - * If null, Security\Core's AccessDeniedException will be used. |
43 |
| - */ |
44 | 37 | public ?int $statusCode = null,
|
45 |
| - |
46 |
| - /** |
47 |
| - * If set, will add the exception code to thrown exception. |
48 |
| - */ |
49 | 38 | public ?int $exceptionCode = null,
|
50 | 39 | ) {
|
51 | 40 | }
|
|
0 commit comments