You are here

protected static function VersionNegotiator::throwBadRequestHttpException in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/jsonapi/src/Revisions/VersionNegotiator.php \Drupal\jsonapi\Revisions\VersionNegotiator::throwBadRequestHttpException()
  2. 10 core/modules/jsonapi/src/Revisions/VersionNegotiator.php \Drupal\jsonapi\Revisions\VersionNegotiator::throwBadRequestHttpException()

Throws a cacheable error exception.

Parameters

string $resource_version_identifier: The user input for the revision negotiation.

Throws

\Drupal\Core\Http\Exception\CacheableBadRequestHttpException

1 call to VersionNegotiator::throwBadRequestHttpException()
VersionNegotiator::getRevision in core/modules/jsonapi/src/Revisions/VersionNegotiator.php
Gets a negotiated entity revision.

File

core/modules/jsonapi/src/Revisions/VersionNegotiator.php, line 106

Class

VersionNegotiator
Provides a version negotiator manager.

Namespace

Drupal\jsonapi\Revisions

Code

protected static function throwBadRequestHttpException($resource_version_identifier) {
  $cacheability = (new CacheableMetadata())
    ->addCacheContexts([
    'url.query_args:' . ResourceVersionRouteEnhancer::RESOURCE_VERSION_QUERY_PARAMETER,
  ]);
  $message = sprintf('An invalid resource version identifier, `%s`, was provided.', $resource_version_identifier);
  throw new CacheableBadRequestHttpException($cacheability, $message);
}