Skip to content

Commit 6f3e00f

Browse files
authored
Merge pull request #330 from philippecarle/operation-defaults
Add missing Symfony Routing options to operations configuration
2 parents fe132fd + fd5bc35 commit 6f3e00f

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

core/operations.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ use ApiPlatform\Core\Annotation\ApiResource;
125125

126126
/**
127127
* @ApiResource(itemOperations={
128-
* "get"={"method"="GET", "path"="/grimoire/{id}", "requirements"={"id"="\d+"}},
128+
* "get"={"method"="GET", "path"="/grimoire/{id}", "requirements"={"id"="\d+"}, "defaults"={"color"="brown"}, "options"={"my_option"="my_option_value", "schemes"={"https"}, "host"="{subdomain}.api-platform.com"}},
129129
* "put"={"method"="PUT", "path"="/grimoire/{id}/update", "hydra_context"={"foo"="bar"}},
130130
* })
131131
*/
@@ -146,6 +146,12 @@ AppBundle\Entity\Book:
146146
path: '/grimoire/{id}'
147147
requirements:
148148
id: '\d+'
149+
defaults:
150+
color: 'brown'
151+
host: '{subdomain}.api-platform.com'
152+
schemes: ['https']
153+
options:
154+
my_option: 'my_option_value'
149155
put:
150156
method: 'PUT'
151157
path: '/grimoire/{id}/update'
@@ -171,6 +177,16 @@ Or in XML:
171177
<attribute name="requirements">
172178
<attribute name="id">\d+</attribute>
173179
</attribute>
180+
<attribute name="defaults">
181+
<attribute name="color">brown</attribute>
182+
</attribute>
183+
<attribute name="options">
184+
<attribute name="color">brown</attribute>
185+
</attribute>
186+
<attribute name="schemes">
187+
<attribute>https</attribute>
188+
</attribute>
189+
<attribute name="host">{subdomain}.api-platform.com</attribute>
174190
</itemOperation>
175191
<itemOperation name="put">
176192
<attribute name="method">PUT</attribute>

0 commit comments

Comments
 (0)