You are here

protected function JsonApiGenerator::getRoutTypeFromName 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::getRoutTypeFromName()

Gets the route from the name if possible.

Parameters

string $route_name: The route name.

Return value

string The route type.

5 calls to JsonApiGenerator::getRoutTypeFromName()
JsonApiGenerator::getEntityResponsesJsonApi in src/Plugin/openapi/OpenApiGenerator/JsonApiGenerator.php
JsonApiGenerator::getMethodParameters in src/Plugin/openapi/OpenApiGenerator/JsonApiGenerator.php
Get the parameters array for a method on a route.
JsonApiGenerator::getRouteMethodDescription in src/Plugin/openapi/OpenApiGenerator/JsonApiGenerator.php
Gets description of a method on a route.
JsonApiGenerator::getRouteMethodSummary in src/Plugin/openapi/OpenApiGenerator/JsonApiGenerator.php
Gets description of a method on a route.
JsonApiGenerator::relatedResourceType in src/Plugin/openapi/OpenApiGenerator/JsonApiGenerator.php
Gets the related Resource Type.

File

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

Class

JsonApiGenerator
Defines an OpenApi Schema Generator for the JsonApi module.

Namespace

Drupal\openapi_jsonapi\Plugin\openapi\OpenApiGenerator

Code

protected function getRoutTypeFromName($route_name) {
  if (strpos($route_name, '.related') !== FALSE) {
    return 'related';
  }
  if (strpos($route_name, '.relationship') !== FALSE) {
    return 'relationship';
  }
  $route_name_parts = explode('.', $route_name);
  return isset($route_name_parts[2]) ? $route_name_parts[2] : '';
}