Skip to content

Commit

Permalink
When registering a controller with a Controller annotation using the …
Browse files Browse the repository at this point in the history
…annot.controllers option, any prefix will be prepended to the prefix set by the Controller annotation.
  • Loading branch information
danadesrosiers committed Nov 28, 2014
1 parent 2f4f1a8 commit d279a9f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/AnnotationService.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ public function registerController($controllerName, Controller $defaultControlle

if (!($controllerAnnotation instanceof Controller)) {
$controllerAnnotation = $defaultControllerAnnotation;
} else if ($defaultControllerAnnotation instanceof Controller) {
$controllerAnnotation->prefix = $defaultControllerAnnotation->prefix . $controllerAnnotation->prefix;
}

if ($controllerAnnotation instanceof Controller) {
Expand Down
12 changes: 12 additions & 0 deletions test/AnnotationServiceProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,18 @@ public function testRegisterControllersWithGroups()
$this->assertEndPointStatus(self::GET_METHOD, '/group2/test2', self::STATUS_OK, $options);
}

public function testGroupAndControllerPrefix()
{
$options = array(
"annot.controllers" => array(
'group' => array("DDesrosiers\\Test\\SilexAnnotations\\Controller\\TestController")
)
);

// both the annot.controller prefix and the Controller annotation prefix should be respected
$this->assertEndPointStatus(self::GET_METHOD, '/group/test/test1', self::STATUS_OK, $options);
}

public function testRegisterControllersByDirectoryProvider()
{
$subDirFqcn = self::CONTROLLER_NAMESPACE."SubDir\\SubDirTestController";
Expand Down

0 comments on commit d279a9f

Please sign in to comment.