Skip to content

Commit f94c22e

Browse files
committed
Fix operations configuration
1 parent 6fe83ad commit f94c22e

File tree

1 file changed

+38
-30
lines changed

1 file changed

+38
-30
lines changed

core/operations.md

Lines changed: 38 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,9 @@ class Book
7070
```
7171

7272
```yaml
73-
# src/AppBundle/Resources/config/api_resources.yml
74-
product:
75-
class: 'AppBundle\Entity\Book'
73+
# app/config/api_resources.yml
74+
75+
AppBundle\Entity\Book:
7676
collectionOperations:
7777
get:
7878
method: 'GET' # nothing more to add if we want to keep the default controller
@@ -82,16 +82,17 @@ product:
8282
```
8383
8484
```xml
85-
<!-- src/AppBundle/Resources/config/api_resources.xml -->
85+
<!-- app/config/api_resources.xml -->
86+
8687
<?xml version="1.0" encoding="UTF-8" ?>
8788
<resources>
8889
<resource class="AppBundle\Entity\Book">
89-
<itemOperations type="collection">
90-
<operation key="get" method="GET" />
91-
</itemOperations>
92-
<collectionOperations type="collection">
93-
<operation key="get" method="GET" />
94-
</collectionOperations>
90+
<itemOperation name="get">
91+
<attribute name="method">GET</attribute>
92+
</itemOperation>
93+
<collectionOperation name="get">
94+
<attribute name="method">GET</attribute>
95+
</collectionOperation>
9596
</resource>
9697
</resources>
9798
```
@@ -130,9 +131,9 @@ class Book
130131
```
131132

132133
```yaml
133-
# src/AppBundle/Resources/config/api_resources.yml
134-
product:
135-
class: 'AppBundle\Entity\Book'
134+
# app/config/api_resources.yml
135+
136+
AppBundle\Entity\Book:
136137
itemOperations:
137138
get:
138139
method: 'GET'
@@ -144,18 +145,22 @@ product:
144145
```
145146
146147
```xml
147-
<!-- src/Acme/BlogBundle/Resources/config/api_resources.xml -->
148+
<!-- app/config/api_resources.xml -->
149+
148150
<?xml version="1.0" encoding="UTF-8" ?>
149151
<resources>
150152
<resource class="AppBundle\Entity\Book">
151-
<itemOperations type="collection">
152-
<operation key="get" method="GET" />
153-
<operation key="put" method="GET" path="/grimoire/{id}/update">
154-
<attribute key="hydra_context" type="collection">
155-
<attribute key="foo">bar</attribute>
156-
</attribute>
157-
</operation>
158-
</itemOperations>
153+
<itemOperation name="get">
154+
<attribute name="method">GET</attribute>
155+
<attribute name="path">/grimoire/{id}</attribute>
156+
</itemOperation>
157+
<itemOperation name="put">
158+
<attribute name="method">PUT</attribute>
159+
<attribute name="path">/grimoire/{id}/update</attribute>
160+
<attribute name="hydra_context">
161+
<attribute name="foo">bar</attribute>
162+
</attribute>
163+
</itemOperation>
159164
</resource>
160165
</resources>
161166
```
@@ -209,9 +214,9 @@ class Book
209214
```
210215

211216
```yaml
212-
# src/AppBundle/Resources/config/resources.yml
213-
product:
214-
class: 'AppBundle\Entity\Book'
217+
# app/config/api_resources.yml
218+
219+
AppBundle\Entity\Book:
215220
itemOperations:
216221
get:
217222
method: 'GET'
@@ -220,14 +225,17 @@ product:
220225
```
221226
222227
```xml
223-
<!-- src/Acme/BlogBundle/Resources/config/resources.xml -->
228+
<!-- app/config/api_resources.xml -->
229+
224230
<?xml version="1.0" encoding="UTF-8" ?>
225231
<resources>
226232
<resource class="AppBundle\Entity\Book">
227-
<itemOperations type="collection">
228-
<operation key="get" method="GET" />
229-
<operation key="special" routeName="book_special" />
230-
</itemOperations>
233+
<itemOperation name="get">
234+
<attribute name="method">GET</attribute>
235+
</itemOperation>
236+
<itemOperation name="special">
237+
<attribute name="route_name">book_special</attribute>
238+
</itemOperation>
231239
</resource>
232240
</resources>
233241
```

0 commit comments

Comments
 (0)