You are here

protected function RestGenerator::getRestSupportedFormats in OpenAPI 8

Returns a list of supported Format on REST.

Return value

array The list of supported formats.

2 calls to RestGenerator::getRestSupportedFormats()
RestGenerator::getConsumes in src/Plugin/openapi/OpenApiGenerator/RestGenerator.php
Get a list of all MIME Type that the API Consumes
RestGenerator::getProduces in src/Plugin/openapi/OpenApiGenerator/RestGenerator.php
Get a list of all MIME Type that the API Produces

File

src/Plugin/openapi/OpenApiGenerator/RestGenerator.php, line 486

Class

RestGenerator
Defines an OpenApi Schema Generator for the Rest module.

Namespace

Drupal\openapi\Plugin\openapi\OpenApiGenerator

Code

protected function getRestSupportedFormats() {
  static $supported_formats = [];
  if (empty($supported_formats)) {
    $resource_configs = $this
      ->getResourceConfigs($this
      ->getOptions());
    if (empty($resource_configs)) {
      return [];
    }
    foreach ($resource_configs as $resource_config) {

      /** @var \Drupal\rest\Plugin\ResourceBase $plugin */
      $resource_plugin = $resource_config
        ->getResourcePlugin();
      foreach ($resource_config
        ->getMethods() as $method) {
        $formats = $this
          ->getMethodSupportedFormats($method, $resource_config);
        $supported_formats = array_unique(array_merge($supported_formats, $formats), SORT_REGULAR);
      }
    }
  }
  return $supported_formats;
}