public function S3fsPathProcessorImageStyles::processInbound in S3 File System 4.0.x
Same name and namespace in other branches
- 8.3 src/PathProcessor/S3fsPathProcessorImageStyles.php \Drupal\s3fs\PathProcessor\S3fsPathProcessorImageStyles::processInbound()
Processes the inbound path.
Implementations may make changes to the request object passed in but should avoid all other side effects. This method can be called to process requests other than the current request.
Parameters
string $path: The path to process, with a leading slash.
\Symfony\Component\HttpFoundation\Request $request: The HttpRequest object representing the request to process. Note, if this method is being called via the path_processor_manager service and is not part of routing, the current request object must be cloned before being passed in.
Return value
string The processed path.
Overrides InboundPathProcessorInterface::processInbound
File
- src/
PathProcessor/ S3fsPathProcessorImageStyles.php, line 33
Class
- S3fsPathProcessorImageStyles
- Defines a path processor to rewrite image styles URLs.
Namespace
Drupal\s3fs\PathProcessorCode
public function processInbound($path, Request $request) {
if ($this
->isImageStylePath($path)) {
// Strip out path prefix.
$rest = preg_replace('|^' . preg_quote(static::IMAGE_STYLE_PATH_PREFIX, '|') . '|', '', $path);
// Get the image style, scheme and path.
if (substr_count($rest, '/') >= 2) {
list($image_style, $scheme, $file) = explode('/', $rest, 3);
if ($this
->isValidScheme($scheme)) {
// Set the file as query parameter.
$request->query
->set('file', $file);
$path = static::IMAGE_STYLE_PATH_PREFIX . $image_style . '/' . $scheme;
}
}
}
return $path;
}