You are here

protected function CdnFarfuturePathProcessor::processFarFuture in CDN 8.3

Process the path for the far future controller.

Parameters

string $path: The path.

\Symfony\Component\HttpFoundation\Request $request: The request.

Return value

string The processed path.

1 call to CdnFarfuturePathProcessor::processFarFuture()
CdnFarfuturePathProcessor::processInbound in src/PathProcessor/CdnFarfuturePathProcessor.php
Processes the inbound path.

File

src/PathProcessor/CdnFarfuturePathProcessor.php, line 49

Class

CdnFarfuturePathProcessor
Defines a path processor to rewrite CDN farfuture URLs.

Namespace

Drupal\cdn\PathProcessor

Code

protected function processFarFuture(string $path, Request $request) : string {

  // Parse the security token, mtime, scheme and root-relative file URL.
  $tail = substr($path, strlen('/cdn/ff/'));
  list($security_token, $mtime, $scheme, $relative_file_url) = explode('/', $tail, 4);
  $returnPath = "/cdn/ff/{$security_token}/{$mtime}/{$scheme}";

  // Set the root-relative file URL as query parameter.
  $request->query
    ->set('relative_file_url', '/' . UrlHelper::encodePath($relative_file_url));

  // Return the same path, but without the trailing file.
  return $returnPath;
}