// Provide a helpful error when a version is specified with an unsafe
// method.
if (!
$request->
isMethodCacheable()) { throw new BadRequestHttpException(sprintf('%s requests with a `%s` query parameter are not supported.',
$request->
getMethod(),
static::RESOURCE_VERSION_QUERY_PARAMETER
));
} $resource_version_identifier =
$request->query->
get(static::RESOURCE_VERSION_QUERY_PARAMETER
);
if (!
static::
isValidVersionIdentifier($resource_version_identifier)) { $cacheability =
(new CacheableMetadata())->
addCacheContexts([static::CACHE_CONTEXT
]);
$message =
sprintf('A resource version identifier was provided in an invalid format: `%s`',
$resource_version_identifier);
throw new CacheableBadRequestHttpException($cacheability,
$message);
} // Determine if the request is for a collection resource.
if ($defaults[RouteObjectInterface::CONTROLLER_NAME
] === Routes::CONTROLLER_SERVICE_NAME . ':getCollection'
) { $latest_version_identifier = 'rel' . VersionNegotiator::SEPARATOR . 'latest-version';
$working_copy_identifier = 'rel' . VersionNegotiator::SEPARATOR . 'working-copy';
// Until Drupal core has a revision access API that works on entity
// queries, filtering is not permitted on non-default revisions.
if ($request->query->
has('filter'
) &&
$resource_version_identifier !==
$latest_version_identifier) { $cache_contexts =
[ 'url.path',