function EntityResource::getRequestLink

Same name in other branches
  1. 9 core/modules/jsonapi/src/Controller/EntityResource.php \Drupal\jsonapi\Controller\EntityResource::getRequestLink()
  2. 8.9.x core/modules/jsonapi/src/Controller/EntityResource.php \Drupal\jsonapi\Controller\EntityResource::getRequestLink()
  3. 10 core/modules/jsonapi/src/Controller/EntityResource.php \Drupal\jsonapi\Controller\EntityResource::getRequestLink()

Get the full URL for a given request object.

Parameters

\Symfony\Component\HttpFoundation\Request $request: The request object.

array|null $query: The query parameters to use. Leave it empty to get the query from the request object.

Return value

\Drupal\Core\Url The full URL.

2 calls to EntityResource::getRequestLink()
EntityResource::buildWrappedResponse in core/modules/jsonapi/src/Controller/EntityResource.php
Builds a response with the appropriate wrapped document.
EntityResource::getPagerLinks in core/modules/jsonapi/src/Controller/EntityResource.php
Get the pager links for a given request object.

File

core/modules/jsonapi/src/Controller/EntityResource.php, line 1264

Class

EntityResource
Process all entity requests.

Namespace

Drupal\jsonapi\Controller

Code

protected static function getRequestLink(Request $request, $query = NULL) {
    if ($query === NULL) {
        return Url::fromUri($request->getUri());
    }
    $uri_without_query_string = $request->getSchemeAndHttpHost() . $request->getBaseUrl() . $request->getPathInfo();
    return Url::fromUri($uri_without_query_string)->setOption('query', $query);
}

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