You are here

protected static function EntityResource::getRequestLink in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/jsonapi/src/Controller/EntityResource.php \Drupal\jsonapi\Controller\EntityResource::getRequestLink()
  2. 9 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.

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);
}