You are here

protected function JsonApiGenerator::getJsonApiRoutes in OpenAPI for JSON:API 8.2

Same name and namespace in other branches
  1. 3.x src/Plugin/openapi/OpenApiGenerator/JsonApiGenerator.php \Drupal\openapi_jsonapi\Plugin\openapi\OpenApiGenerator\JsonApiGenerator::getJsonApiRoutes()

Gets the JSON API routes.

Return value

\Symfony\Component\Routing\Route[] The routes.

1 call to JsonApiGenerator::getJsonApiRoutes()
JsonApiGenerator::getPaths in src/Plugin/openapi/OpenApiGenerator/JsonApiGenerator.php

File

src/Plugin/openapi/OpenApiGenerator/JsonApiGenerator.php, line 250

Class

JsonApiGenerator
Defines an OpenApi Schema Generator for the JsonApi module.

Namespace

Drupal\openapi_jsonapi\Plugin\openapi\OpenApiGenerator

Code

protected function getJsonApiRoutes() {
  $all_routes = $this->routingProvider
    ->getAllRoutes();
  $jsonapi_routes = [];
  $jsonapi_base_path = $this
    ->getJsonApiBase();

  /** @var \Symfony\Component\Routing\Route $route */
  foreach ($all_routes as $route_name => $route) {
    $is_jsonapi = $route
      ->getDefault(JsonApiRoutes::JSON_API_ROUTE_FLAG_KEY);
    $is_entry_point = $route
      ->getPath() === $jsonapi_base_path;
    if (!$is_jsonapi || $is_entry_point) {
      continue;
    }
    $jsonapi_routes[$route_name] = $route;
  }
  return $jsonapi_routes;
}