Skip to content

Commit

Permalink
sync with upstream master
Browse files Browse the repository at this point in the history
  • Loading branch information
tonivdv committed Sep 11, 2013
2 parents d389807 + 5ab242a commit 988d9b8
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 5 deletions.
56 changes: 56 additions & 0 deletions Resources/doc/7-manual-route-definition.md
@@ -0,0 +1,56 @@
Manual definition of routes
=====================================

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.

For a full list of annotations check out FOS/RestBundle/Controller/Annotations

## Delete Route Definition
use FOS\RestBundle\Controller\Annotations\Delete;

/**
* DELETE Route annotation.
* @Delete("/likes/{type}/{typeId}")
*/

## Head Route Definition
use FOS\RestBundle\Controller\Annotations\Head;

/**
* HEAD Route annotation.
* @Head("/likes/{type}/{typeId}")
*/

## Get Route Definition
use FOS\RestBundle\Controller\Annotations\Get;

/**
* GET Route annotation.
* @Get("/likes/{type}/{typeId}")
*/
## Patch Route Definition
use FOS\RestBundle\Controller\Annotations\Patch;

/**
* PATCH Route annotation.
* @Patch("/likes/{type}/{typeId}")
*/
## Post Route Definition
use FOS\RestBundle\Controller\Annotations\Post;

/**
* POST Route annotation.
* @Post("/likes/{type}/{typeId}")
*/
## Put Route Definition
use FOS\RestBundle\Controller\Annotations\Put;

/**
* PUT Route annotation.
* @Put("/likes/{type}/{typeId}")
*/


1 change: 1 addition & 0 deletions Resources/doc/index.md
Expand Up @@ -20,6 +20,7 @@ FOSRestBundle provides several tools to assist in building REST applications:
- [ExceptionController support](4-exception-controller-support.md)
- [Automatic route generation: single RESTful controller](5-automatic-route-generation_single-restful-controller.md) (for simple resources)
- [Automatic route generation: multiple RESTful controllers](6-automatic-route-generation_multiple-restful-controllers.md) (for resources with child/subresources)
- [Manual definition of routes](7-manual-route-definition.md)

### Config reference
Check out the [configuration reference](configuration-reference.md) for a reference on the available configuration options.
Expand Down
1 change: 1 addition & 0 deletions Routing/Loader/Reader/RestActionReader.php
Expand Up @@ -363,6 +363,7 @@ private function generateUrlParts(array $resources, array $arguments, $httpMetho
} elseif (null !== $resource) {
if ((0 === count($arguments) && !in_array($httpMethod, $this->availableHTTPMethods))
|| 'new' === $httpMethod
|| 'post' === $httpMethod
) {
$urlParts[] = $this->inflector->pluralize(strtolower($resource));
} else {
Expand Down
2 changes: 1 addition & 1 deletion Tests/Fixtures/Etalon/prefixed_users_collection.yml
Expand Up @@ -65,7 +65,7 @@ ban_user:

post_user_comment_vote:
method: POST
pattern: /resources/all/users/{slug}/comments/{id}/vote.{_format}
pattern: /resources/all/users/{slug}/comments/{id}/votes.{_format}
controller: ::postUserCommentVoteAction

get_user_topics:
Expand Down
2 changes: 1 addition & 1 deletion Tests/Fixtures/Etalon/resource_controller.yml
Expand Up @@ -65,7 +65,7 @@ ban_article:

post_article_comment_vote:
method: POST
pattern: /articles/{slug}/comments/{id}/vote.{_format}
pattern: /articles/{slug}/comments/{id}/votes.{_format}
controller: ::postCommentVoteAction

check_articlename_article:
Expand Down
2 changes: 1 addition & 1 deletion Tests/Fixtures/Etalon/users_collection.yml
Expand Up @@ -65,7 +65,7 @@ ban_user:

post_user_comment_vote:
method: POST
pattern: /users/{slug}/comments/{id}/vote.{_format}
pattern: /users/{slug}/comments/{id}/votes.{_format}
controller: ::postUserCommentVoteAction

get_user_topics:
Expand Down
2 changes: 1 addition & 1 deletion Tests/Fixtures/Etalon/users_controller.yml
Expand Up @@ -65,7 +65,7 @@ ban_user:

post_user_comment_vote:
method: POST
pattern: /users/{slug}/comments/{id}/vote.{_format}
pattern: /users/{slug}/comments/{id}/votes.{_format}
controller: ::postUserCommentVoteAction

check_username_users:
Expand Down
3 changes: 2 additions & 1 deletion UPGRADING.md
Expand Up @@ -4,8 +4,9 @@ Upgrading
Note as FOSRestBundle is not yet declared stable, this document will be updated to
list important BC breaks.

### Upgrading from 0.13.1
### upgrading from 0.13.1

* POST routes now pluralize the resource name, ie. /users vs. /user
* 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

### upgrading from 0.12.0
Expand Down

0 comments on commit 988d9b8

Please sign in to comment.