Skip to content

Commit 988d9b8

Browse files
committed
sync with upstream master
2 parents d389807 + 5ab242a commit 988d9b8

File tree

8 files changed

+64
-5
lines changed

8 files changed

+64
-5
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
Manual definition of routes
2+
=====================================
3+
4+
If the automatic route generation does not fit your needs, you can manually define a route using simple annotations. This is very helpful if you want to have more than 1 url parameter without having a static word in between them.
5+
6+
For a full list of annotations check out FOS/RestBundle/Controller/Annotations
7+
8+
## Delete Route Definition
9+
use FOS\RestBundle\Controller\Annotations\Delete;
10+
11+
/**
12+
* DELETE Route annotation.
13+
* @Delete("/likes/{type}/{typeId}")
14+
*/
15+
16+
## Head Route Definition
17+
use FOS\RestBundle\Controller\Annotations\Head;
18+
19+
/**
20+
* HEAD Route annotation.
21+
* @Head("/likes/{type}/{typeId}")
22+
*/
23+
24+
## Get Route Definition
25+
use FOS\RestBundle\Controller\Annotations\Get;
26+
27+
/**
28+
* GET Route annotation.
29+
* @Get("/likes/{type}/{typeId}")
30+
*/
31+
32+
## Patch Route Definition
33+
use FOS\RestBundle\Controller\Annotations\Patch;
34+
35+
/**
36+
* PATCH Route annotation.
37+
* @Patch("/likes/{type}/{typeId}")
38+
*/
39+
40+
## Post Route Definition
41+
use FOS\RestBundle\Controller\Annotations\Post;
42+
43+
/**
44+
* POST Route annotation.
45+
* @Post("/likes/{type}/{typeId}")
46+
*/
47+
48+
## Put Route Definition
49+
use FOS\RestBundle\Controller\Annotations\Put;
50+
51+
/**
52+
* PUT Route annotation.
53+
* @Put("/likes/{type}/{typeId}")
54+
*/
55+
56+

Resources/doc/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ FOSRestBundle provides several tools to assist in building REST applications:
2020
- [ExceptionController support](4-exception-controller-support.md)
2121
- [Automatic route generation: single RESTful controller](5-automatic-route-generation_single-restful-controller.md) (for simple resources)
2222
- [Automatic route generation: multiple RESTful controllers](6-automatic-route-generation_multiple-restful-controllers.md) (for resources with child/subresources)
23+
- [Manual definition of routes](7-manual-route-definition.md)
2324

2425
### Config reference
2526
Check out the [configuration reference](configuration-reference.md) for a reference on the available configuration options.

Routing/Loader/Reader/RestActionReader.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,7 @@ private function generateUrlParts(array $resources, array $arguments, $httpMetho
363363
} elseif (null !== $resource) {
364364
if ((0 === count($arguments) && !in_array($httpMethod, $this->availableHTTPMethods))
365365
|| 'new' === $httpMethod
366+
|| 'post' === $httpMethod
366367
) {
367368
$urlParts[] = $this->inflector->pluralize(strtolower($resource));
368369
} else {

Tests/Fixtures/Etalon/prefixed_users_collection.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ ban_user:
6565

6666
post_user_comment_vote:
6767
method: POST
68-
pattern: /resources/all/users/{slug}/comments/{id}/vote.{_format}
68+
pattern: /resources/all/users/{slug}/comments/{id}/votes.{_format}
6969
controller: ::postUserCommentVoteAction
7070

7171
get_user_topics:

Tests/Fixtures/Etalon/resource_controller.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ ban_article:
6565

6666
post_article_comment_vote:
6767
method: POST
68-
pattern: /articles/{slug}/comments/{id}/vote.{_format}
68+
pattern: /articles/{slug}/comments/{id}/votes.{_format}
6969
controller: ::postCommentVoteAction
7070

7171
check_articlename_article:

Tests/Fixtures/Etalon/users_collection.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ ban_user:
6565

6666
post_user_comment_vote:
6767
method: POST
68-
pattern: /users/{slug}/comments/{id}/vote.{_format}
68+
pattern: /users/{slug}/comments/{id}/votes.{_format}
6969
controller: ::postUserCommentVoteAction
7070

7171
get_user_topics:

Tests/Fixtures/Etalon/users_controller.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ ban_user:
6565

6666
post_user_comment_vote:
6767
method: POST
68-
pattern: /users/{slug}/comments/{id}/vote.{_format}
68+
pattern: /users/{slug}/comments/{id}/votes.{_format}
6969
controller: ::postUserCommentVoteAction
7070

7171
check_username_users:

UPGRADING.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ Upgrading
44
Note as FOSRestBundle is not yet declared stable, this document will be updated to
55
list important BC breaks.
66

7-
### Upgrading from 0.13.1
7+
### upgrading from 0.13.1
88

9+
* POST routes now pluralize the resource name, ie. /users vs. /user
910
* The response for non-valid Forms has changed. See https://github.com/FriendsOfSymfony/FOSRestBundle/blob/master/Resources/doc/2-the-view-layer.md#forms-and-views
1011

1112
### upgrading from 0.12.0

0 commit comments

Comments
 (0)