You are here

protected static function VersionNegotiator::throwBadRequestHttpException in Drupal 10

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

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