File tree Expand file tree Collapse file tree 1 file changed +24
-1
lines changed Expand file tree Collapse file tree 1 file changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -462,6 +462,29 @@ class Question
462
462
}
463
463
` ` `
464
464
465
+ # ## Access Control of Subresources
466
+
467
+ The `subresourceOperations` attribute also allows you to add an access control on each path with the attribute `access_control`.
468
+
469
+ ` ` ` php
470
+ <?php
471
+ // api/src/Entity/Question.php
472
+
473
+ /**
474
+ * ...
475
+ * @ApiResource(
476
+ * subresourceOperations={
477
+ * "answer_get_subresource"= {
478
+ * "method"="GET",
479
+ * "access_control"="has_role('ROLE_AUTHENTICATED')"
480
+ * }
481
+ * }
482
+ * )
483
+ class Question
484
+ {
485
+ }
486
+ ` ` `
487
+
465
488
# ## Control the Depth of Subresources
466
489
467
490
You can control depth of subresources with the parameter `maxDepth`. For example, if `Answer` entity also have subresource
@@ -663,7 +686,7 @@ use Symfony\Component\Serializer\Annotation\Groups;
663
686
class Book
664
687
{
665
688
//...
666
-
689
+
667
690
/**
668
691
* @Groups("special")
669
692
*/
You can’t perform that action at this time.
0 commit comments