We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent f8d876a commit 585e2b2Copy full SHA for 585e2b2
core/security.md
@@ -100,3 +100,23 @@ class Book
100
// ...
101
}
102
```
103
+
104
+Alternatively, using YAML:
105
106
+```yaml
107
+# api/config/api_platform/resources.yaml
108
+App\Entity\Book:
109
+ attributes:
110
+ access_control: 'is_granted("ROLE_USER")'
111
+ collectionOperations:
112
+ post:
113
+ method: 'POST'
114
+ access_control: 'is_granted("ROLE_ADMIN")'
115
+ access_control_message: 'Only admins can add books.'
116
+ itemOperations:
117
+ get:
118
+ method: 'GET'
119
+ access_control: 'is_granted("ROLE_USER") and object.owner == user'
120
+ access_control_message: 'Sorry, but you are not the book owner.'
121
+ # ...
122
+```
0 commit comments