Skip to content

Commit 33fc33f

Browse files
committed
Merge pull request #792 from kix/issue-770
Fix #770
2 parents 63bfcc4 + 1948db1 commit 33fc33f

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

Routing/Loader/Reader/RestActionReader.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ public function read(RestRouteCollection $collection, \ReflectionMethod $method,
179179
}
180180

181181
// generated parameters
182-
$routeName = $this->namePrefix.strtolower($routeName);
182+
$routeName = strtolower($routeName);
183183
$pattern = implode('/', $urlParts);
184184
$defaults = array('_controller' => $method->getName());
185185
$requirements = array('_method' => strtoupper($httpMethod));
@@ -546,13 +546,15 @@ private function addRoute(RestRouteCollection $collection, $routeName, $route, $
546546
$routeName = $routeName.$annotation->getName();
547547
}
548548

549+
$fullRouteName = $this->namePrefix.$routeName;
550+
549551
if ($isCollection && !$isInflectable) {
550-
$collection->add(self::COLLECTION_ROUTE_PREFIX.$routeName, $route);
551-
if (!$collection->get($routeName)) {
552-
$collection->add($routeName, clone $route);
552+
$collection->add($this->namePrefix.self::COLLECTION_ROUTE_PREFIX.$routeName, $route);
553+
if (!$collection->get($fullRouteName)) {
554+
$collection->add($fullRouteName, clone $route);
553555
}
554556
} else {
555-
$collection->add($routeName, $route);
557+
$collection->add($fullRouteName, $route);
556558
}
557559
}
558560
}

Tests/Routing/Loader/RestRouteLoaderTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,18 @@ public function testInformationFixture()
266266
$this->assertNotSame($getRoute, $cgetRoute);
267267
}
268268

269+
/**
270+
* @see https://github.com/FriendsOfSymfony/FOSRestBundle/issues/770
271+
* @see https://github.com/FriendsOfSymfony/FOSRestBundle/pull/792
272+
*/
273+
public function testNamePrefixIsPrependingCorrectly()
274+
{
275+
$collection = $this->loadFromControllerFixture('InformationController', 'prefix_');
276+
277+
$this->assertNotNull($collection->get('prefix_get_information'));
278+
$this->assertNotNull($collection->get('prefix_cget_information'));
279+
}
280+
269281
/**
270282
* Load routes collection from fixture class under Tests\Fixtures directory.
271283
*

0 commit comments

Comments
 (0)