mirror of
https://github.com/retailcrm/NelmioApiDocBundle.git
synced 2025-02-02 15:51:48 +03:00
allow areas annotation for controller class (#1528)
Co-authored-by: pchol <spchols@gmail.com> Co-authored-by: Guilhem Niot <guilhem@gniot.fr>
This commit is contained in:
parent
883d7b6c89
commit
8f646b8484
@ -120,19 +120,24 @@ final class FilteredRouteCollectionBuilder
|
||||
return true;
|
||||
}
|
||||
|
||||
$method = $this->controllerReflector->getReflectionMethod(
|
||||
$route->getDefault('_controller') ?? ''
|
||||
);
|
||||
if (null === $method) {
|
||||
$classAndMethod = $this->controllerReflector->getReflectionClassAndMethod($route->getDefault('_controller'));
|
||||
|
||||
if (null === $classAndMethod) {
|
||||
return false;
|
||||
}
|
||||
|
||||
list($class, $method) = $classAndMethod;
|
||||
|
||||
/** @var Areas|null $areas */
|
||||
$areas = $this->annotationReader->getMethodAnnotation(
|
||||
$method,
|
||||
Areas::class
|
||||
);
|
||||
|
||||
if (null === $areas) {
|
||||
$areas = $this->annotationReader->getClassAnnotation($class, Areas::class);
|
||||
}
|
||||
|
||||
return (null !== $areas) ? $areas->has($this->area) : false;
|
||||
}
|
||||
}
|
||||
|
@ -177,9 +177,10 @@ class FilteredRouteCollectionBuilderTest extends TestCase
|
||||
$routes->add($name, $route);
|
||||
$area = 'area';
|
||||
|
||||
$reflectionClassStub = $this->createMock(\ReflectionClass::class);
|
||||
$reflectionMethodStub = $this->createMock(\ReflectionMethod::class);
|
||||
$controllerReflectorStub = $this->createMock(ControllerReflector::class);
|
||||
$controllerReflectorStub->method('getReflectionMethod')->willReturn($reflectionMethodStub);
|
||||
$controllerReflectorStub->method('getReflectionClassAndMethod')->willReturn([$reflectionClassStub, $reflectionMethodStub]);
|
||||
|
||||
$annotationReader = $this->createMock(Reader::class);
|
||||
$annotationReader
|
||||
|
Loading…
x
Reference in New Issue
Block a user