File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -114,6 +114,7 @@ App\Entity\Book:
114
114
115
115
The previous example can also be written with an explicit method definition:
116
116
117
+ [ codeSelector]
117
118
``` php
118
119
<?php
119
120
// api/src/Entity/Book.php
@@ -135,6 +136,39 @@ class Book
135
136
}
136
137
```
137
138
139
+ ``` yaml
140
+ # api/config/api_platform/resources.yaml
141
+ App\Entity\Book :
142
+ collectionOperations :
143
+ get :
144
+ method : GET
145
+ itemOperations :
146
+ get :
147
+ method : GET
148
+ ` ` `
149
+
150
+ ` ` ` xml
151
+ <?xml version="1.0" encoding="UTF-8" ?>
152
+ <!-- api/config/api_platform/resources.xml -->
153
+
154
+ <resources xmlns="https://api-platform.com/schema/metadata"
155
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
156
+ xsi:schemaLocation="https://api-platform.com/schema/metadata
157
+ https://api-platform.com/schema/metadata/metadata-2.0.xsd">
158
+ <resource class="App\Entity\Book">
159
+ <collectionOperations>
160
+ <collectionOperation name="get" />
161
+ </collectionOperations>
162
+ <itemOperations>
163
+ <itemOperation name="get">
164
+ <attribute name="method">GET</attribute>
165
+ </itemOperation>
166
+ </itemOperations>
167
+ </resource>
168
+ </resources>
169
+ ```
170
+ [ /codeSelector]
171
+
138
172
API Platform Core is smart enough to automatically register the applicable Symfony route referencing a built-in CRUD action
139
173
just by specifying the method name as key, or by checking the explicitly configured HTTP method.
140
174
You can’t perform that action at this time.
0 commit comments