diff --git a/src/AnnotationService.php b/src/AnnotationService.php index a498a5f..5f78ea9 100755 --- a/src/AnnotationService.php +++ b/src/AnnotationService.php @@ -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) { diff --git a/test/AnnotationServiceProviderTest.php b/test/AnnotationServiceProviderTest.php index 23ed208..e0d7c05 100755 --- a/test/AnnotationServiceProviderTest.php +++ b/test/AnnotationServiceProviderTest.php @@ -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";