You are here

public static function Routes::getResourceTypeNameFromParameters in JSON:API 8

Same name and namespace in other branches
  1. 8.2 src/Routing/Routes.php \Drupal\jsonapi\Routing\Routes::getResourceTypeNameFromParameters()

Gets the resource type from a route or request's parameters.

Parameters

array $parameters: An array of parameters. These may be obtained from a route's parameter defaults or from a request object.

Return value

\Drupal\jsonapi\ResourceType\ResourceType|null The resource type, NULL if one cannot be found from the given parameters.

6 calls to Routes::getResourceTypeNameFromParameters()
DefaultExceptionSubscriber::isJsonApiExceptionEvent in src/EventSubscriber/DefaultExceptionSubscriber.php
Check if the error should be formatted using JSON API.
EntityUuidConverter::applies in src/ParamConverter/EntityUuidConverter.php
Determines if the converter applies to a specific route and variable.
JsonApiParamEnhancer::applies in src/Routing/JsonApiParamEnhancer.php
Declares if the route enhancer applies to the given route.
JsonApiParamEnhancer::enhance in src/Routing/JsonApiParamEnhancer.php
Update the defaults based on its own data and the request.
RouteEnhancer::applies in src/Routing/RouteEnhancer.php
Declares if the route enhancer applies to the given route.

... See full list

File

src/Routing/Routes.php, line 269

Class

Routes
Defines dynamic routes.

Namespace

Drupal\jsonapi\Routing

Code

public static function getResourceTypeNameFromParameters(array $parameters) {
  if (isset($parameters[static::JSON_API_ROUTE_FLAG_KEY]) && $parameters[static::JSON_API_ROUTE_FLAG_KEY]) {
    return isset($parameters[static::RESOURCE_TYPE_KEY]) ? $parameters[static::RESOURCE_TYPE_KEY] : NULL;
  }
  return NULL;
}