Skip to content

Commit dfdd274

Browse files
author
Jens Averkamp
committed
Change default behavior to keep bc
1 parent ee5b089 commit dfdd274

File tree

5 files changed

+20
-15
lines changed

5 files changed

+20
-15
lines changed

Routing/Loader/Reader/RestActionReader.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,12 @@ private function addRoute(RestRouteCollection $collection, $routeName, $route, $
537537
{
538538
if ($annotation && null !== $annotation->getName()) {
539539
$options = $annotation->getOptions();
540-
$routeName = empty($options['method_prefix']) ? $annotation->getName() : $routeName.$annotation->getName();
540+
541+
if(isset($options['method_prefix']) && false === $options['method_prefix']) {
542+
$routeName = $annotation->getName();
543+
} else {
544+
$routeName = $routeName.$annotation->getName();
545+
}
541546
}
542547

543548
$fullRouteName = $this->namePrefix.$routeName;

Tests/Fixtures/Controller/AnnotatedConditionalUsersController.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,10 +136,10 @@ public function conditionalUserAction()
136136
{}
137137

138138
/**
139-
* @Link("/users1", name="multipleget_users_a_link_method", condition="context.getMethod() in ['LINK'] and request.headers.get('User-Agent') matches '/firefox/i'")
140-
* @Get("/users2", name="multipleget_users_a_get_method", condition="context.getMethod() in ['GET'] and request.headers.get('User-Agent') matches '/firefox/i'")
141-
* @Get("/users3", name="multipleget_users_an_other_get_method")
142-
* @Post("/users4", name="multipleget_users_a_post_method", condition="context.getMethod() in ['POST'] and request.headers.get('User-Agent') matches '/firefox/i'")
139+
* @Link("/users1", name="_a_link_method", condition="context.getMethod() in ['LINK'] and request.headers.get('User-Agent') matches '/firefox/i'")
140+
* @Get("/users2", name="_a_get_method", condition="context.getMethod() in ['GET'] and request.headers.get('User-Agent') matches '/firefox/i'")
141+
* @Get("/users3", name="_an_other_get_method")
142+
* @Post("/users4", name="_a_post_method", condition="context.getMethod() in ['POST'] and request.headers.get('User-Agent') matches '/firefox/i'")
143143
*
144144
*/
145145
public function multiplegetUsersAction()

Tests/Fixtures/Controller/AnnotatedUsersController.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -131,18 +131,18 @@ public function customUserAction($slug)
131131
{}
132132

133133
/**
134-
* @Link("/users1", name="multipleget_users_a_link_method")
135-
* @Get("/users2", name="multipleget_users_a_get_method")
136-
* @Get("/users3", name="multipleget_users_an_other_get_method")
137-
* @Post("/users4", name="multipleget_users_a_post_method")
134+
* @Link("/users1", name="_a_link_method")
135+
* @Get("/users2", name="_a_get_method")
136+
* @Get("/users3", name="_an_other_get_method")
137+
* @Post("/users4", name="_a_post_method")
138138
*
139139
*/
140140
public function multiplegetUsersAction()
141141
{}
142142

143143
/**
144-
* @POST("/users1/{foo}", name="_foo", options={"method_prefix" = true })
145-
* @POST("/users2/{foo}", name="_bar", options={"method_prefix" = true })
144+
* @POST("/users1/{foo}", name="post_users_foo", options={ "method_prefix" = false })
145+
* @POST("/users2/{foo}", name="post_users_bar", options={ "method_prefix" = false })
146146
*
147147
*/
148148
public function multiplepostUsersAction()

Tests/Fixtures/Etalon/annotated_users_controller.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,11 @@ multipleget_users_a_link_method:
7676
controller: ::multiplegetUsersAction
7777
requirements: {_method: LINK}
7878

79-
multiplepost_users_foo:
79+
post_users_foo:
8080
pattern: /users1/{foo}.{_format}
8181
controller: ::multiplepostUsersAction
8282
requirements: {_method: POST}
83-
multiplepost_users_bar:
83+
post_users_bar:
8484
pattern: /users2/{foo}.{_format}
8585
controller: ::multiplepostUsersAction
8686
requirements: {_method: POST}

Tests/Routing/Loader/RestRouteLoaderTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,8 +286,8 @@ public function testNameMethodPrefixIsPrependingCorrectly()
286286
{
287287
$collection = $this->loadFromControllerFixture('AnnotatedUsersController');
288288

289-
$this->assertNotNull($collection->get('multiplepost_users_foo'));
290-
$this->assertNotNull($collection->get('multiplepost_users_bar'));
289+
$this->assertNotNull($collection->get('post_users_foo'), 'route for "post_users_foo" does not exist');
290+
$this->assertNotNull($collection->get('post_users_bar'), 'route for "post_users_bar" does not exist');
291291
}
292292

293293
/**

0 commit comments

Comments
 (0)