You are here

protected static function OffsetLimitPaginator::getRequestLink in JSON:API Resources 8

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.

1 call to OffsetLimitPaginator::getRequestLink()
OffsetLimitPaginator::getPaginationLinks in src/Unstable/Entity/Query/Pagination/OffsetLimitPaginator.php
Get pagination links. Must not be called before executing the query.

File

src/Unstable/Entity/Query/Pagination/OffsetLimitPaginator.php, line 211

Class

OffsetLimitPaginator
A paginator for handling offset-limit pagination in JSON:API request.

Namespace

Drupal\jsonapi_resources\Unstable\Entity\Query\Pagination

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