function Routes::getResourceTypeNameFromParameters

Same name in other branches
  1. 9 core/modules/jsonapi/src/Routing/Routes.php \Drupal\jsonapi\Routing\Routes::getResourceTypeNameFromParameters()
  2. 8.9.x core/modules/jsonapi/src/Routing/Routes.php \Drupal\jsonapi\Routing\Routes::getResourceTypeNameFromParameters()
  3. 10 core/modules/jsonapi/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.

4 calls to Routes::getResourceTypeNameFromParameters()
DefaultExceptionSubscriber::isJsonApiExceptionEvent in core/modules/jsonapi/src/EventSubscriber/DefaultExceptionSubscriber.php
Check if the error should be formatted using JSON:API.
EntityUuidConverter::applies in core/modules/jsonapi/src/ParamConverter/EntityUuidConverter.php
Determines if the converter applies to a specific route and variable.
ResourceVersionRouteEnhancer::enhance in core/modules/jsonapi/src/Revisions/ResourceVersionRouteEnhancer.php
Updates the defaults for a route definition based on the request.
RouteEnhancer::enhance in core/modules/jsonapi/src/Routing/RouteEnhancer.php
Updates the defaults for a route definition based on the request.

File

core/modules/jsonapi/src/Routing/Routes.php, line 466

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 $parameters[static::RESOURCE_TYPE_KEY] ?? NULL;
    }
    return NULL;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.