mirror of
https://github.com/retailcrm/NelmioApiDocBundle.git
synced 2025-02-02 15:51:48 +03:00
Add a getRoutes method and change property privacy
Overwriting this class for route filtering is not possible / easy at the moment. This commit allow to use our own getRoutes method.
This commit is contained in:
parent
65c634d32b
commit
d2757b6c50
@ -28,22 +28,22 @@ class ApiDocExtractor
|
||||
/**
|
||||
* @var \Symfony\Component\DependencyInjection\ContainerInterface
|
||||
*/
|
||||
private $container;
|
||||
protected $container;
|
||||
|
||||
/**
|
||||
* @var \Symfony\Component\Routing\RouterInterface
|
||||
*/
|
||||
private $router;
|
||||
protected $router;
|
||||
|
||||
/**
|
||||
* @var \Doctrine\Common\Annotations\Reader
|
||||
*/
|
||||
private $reader;
|
||||
protected $reader;
|
||||
|
||||
/**
|
||||
* @var array \Nelmio\ApiDocBundle\Parser\ParserInterface
|
||||
*/
|
||||
private $parsers = array();
|
||||
protected $parsers = array();
|
||||
|
||||
public function __construct(ContainerInterface $container, RouterInterface $router, Reader $reader)
|
||||
{
|
||||
@ -52,6 +52,18 @@ class ApiDocExtractor
|
||||
$this->reader = $reader;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a list of route to inspect for ApiDoc annotation
|
||||
* You can extend this method if you don't want all the routes
|
||||
* to be included.
|
||||
*
|
||||
* @return array of Route
|
||||
*/
|
||||
public function getRoutes()
|
||||
{
|
||||
return $this->router->getRouteCollection()->all();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of data where each data is an array with the following keys:
|
||||
* - annotation
|
||||
@ -64,7 +76,7 @@ class ApiDocExtractor
|
||||
$array = array();
|
||||
$resources = array();
|
||||
|
||||
foreach ($this->router->getRouteCollection()->all() as $route) {
|
||||
foreach ($this->getRoutes() as $route) {
|
||||
if ($method = $this->getReflectionMethod($route->getDefault('_controller'))) {
|
||||
if ($annotation = $this->reader->getMethodAnnotation($method, self::ANNOTATION_CLASS)) {
|
||||
if ($annotation->isResource()) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user