Skip to content

Commit 74ebd27

Browse files
lyrixxdunglas
authored andcommitted
Doc. how to change the path of a subresource (#370)
* Doc. how to change the path of a subresource
1 parent be57e2c commit 74ebd27

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

core/operations.md

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,31 @@ Note that the operation name, here `api_questions_answer_get_subresource`, is th
357357
It'll be automatically set to `$resources_$subresource(s)_get_subresource`. To find the correct operation name you
358358
may use `bin/console debug:router`.
359359

360-
### Control the depth of subresources
360+
### Control the Path of Subresources
361+
362+
You can control the path of subresources with the `path` option of the `subresourceOperations` parameter:
363+
364+
```php
365+
<?php
366+
// src/AppBundle/Entity/Question.php
367+
368+
/**
369+
* @ORM\Entity()
370+
* @ApiResource(
371+
* subresourceOperations={
372+
* "answer_get_subresource"= {
373+
* "method"="GET",
374+
* "path"="/questions/{id}/all-answers",
375+
* },
376+
* },
377+
* )
378+
*/
379+
class Question
380+
{
381+
}
382+
```
383+
384+
### Control the Depth of Subresources
361385

362386
You can control depth of subresources with the parameter `maxDepth`. For example, if `Answer` entity also have subresource such as `comments`and you don't want the route `api/questions/{id}/answers/{id}/comments` to be generated. You can do this by adding the parameter maxDepth in ApiSubresource annotation or yml/xml file configuration.
363387

0 commit comments

Comments
 (0)