2016-06-30 23:30:37 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This file is part of the ApiDocBundle package.
|
|
|
|
*
|
|
|
|
* (c) EXSyst
|
|
|
|
*
|
|
|
|
* For the full copyright and license information, please view the LICENSE
|
|
|
|
* file that was distributed with this source code.
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace EXSyst\Bundle\ApiDocBundle\Extractor\Routing;
|
|
|
|
|
|
|
|
use gossi\swagger\Operation;
|
|
|
|
use gossi\swagger\Swagger;
|
|
|
|
use Symfony\Component\Routing\Route;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @internal
|
|
|
|
*/
|
|
|
|
trait RouteExtractorTrait
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @internal
|
|
|
|
*
|
|
|
|
* @return Operation[]
|
|
|
|
*/
|
|
|
|
private function getOperations(Swagger $api, Route $route)
|
|
|
|
{
|
2016-07-12 00:33:55 +02:00
|
|
|
$path = $api->getPaths()->get($route->getPath());
|
2016-06-30 23:30:37 +02:00
|
|
|
$methods = $route->getMethods() ?: Swagger::$METHODS;
|
|
|
|
foreach ($methods as $method) {
|
|
|
|
$method = strtolower($method);
|
|
|
|
if (!in_array($method, Swagger::$METHODS)) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
$operations[] = $path->getOperation($method);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $operations;
|
|
|
|
}
|
|
|
|
}
|