protected function RestGenerator::getMethodSupportedFormats in OpenAPI 8
List of supported Serializer Formats for HTTP Method on a Rest Resource.
Parameters
string $method: The HTTP method for generating the MIME Types. Example: GET, POST, etc.
\Drupal\rest\RestResourceConfigInterface $resource_config: The resource configuration.
Return value
array The list of MIME Types
2 calls to RestGenerator::getMethodSupportedFormats()
- RestGenerator::getPaths in src/
Plugin/ openapi/ OpenApiGenerator/ RestGenerator.php - Returns the paths information.
- RestGenerator::getRestSupportedFormats in src/
Plugin/ openapi/ OpenApiGenerator/ RestGenerator.php - Returns a list of supported Format on REST.
File
- src/
Plugin/ openapi/ OpenApiGenerator/ RestGenerator.php, line 443
Class
- RestGenerator
- Defines an OpenApi Schema Generator for the Rest module.
Namespace
Drupal\openapi\Plugin\openapi\OpenApiGeneratorCode
protected function getMethodSupportedFormats($method, RestResourceConfigInterface $resource_config) {
if (empty($method)) {
return [];
}
// The route ID.
$route_id = "rest.{$resource_config->id()}.{$method}";
// First Check the supported formats on the route level.
/** @var \Symfony\Component\Routing\Route[] $route */
$routes = $this->routingProvider
->getRoutesByNames([
$route_id,
]);
if (!empty($routes) && array_key_exists($route_id, $routes) && ($formats = $routes[$route_id]
->getRequirement('_format'))) {
return explode('|', $formats);
}
// If no route level format was found, lets use
// the RestResourceConfig formats for the given HTTP method.
return $resource_config
->getFormats($method);
}