public function PathProcessorBackgroundImage::processInbound in Background Image 2.x
Same name and namespace in other branches
- 8 src/PathProcessor/PathProcessorBackgroundImage.php \Drupal\background_image\PathProcessor\PathProcessorBackgroundImage::processInbound()
- 2.0.x src/PathProcessor/PathProcessorBackgroundImage.php \Drupal\background_image\PathProcessor\PathProcessorBackgroundImage::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/ PathProcessorBackgroundImage.php, line 46
Class
- PathProcessorBackgroundImage
- Defines a path processor to rewrite background image CSS URLs.
Namespace
Drupal\background_image\PathProcessorCode
public function processInbound($path, Request $request) {
$directory_path = $this->streamWrapperManager
->getViaScheme('public')
->getDirectoryPath();
// Immediately return if not a background image CSS path.
if (strpos($path, '/' . $directory_path . '/background_image/css/') !== 0 && strpos($path, '/system/files/background_image/css/') !== 0) {
return $path;
}
// Redirect minified CSS to non-minified CSS if site does is not able
// to minify CSS. Note: the Background Image Manager service cannot be
// injected because it will cause a circular reference. Instead, it must
// be accessed during runtime.
if (preg_match('/\\.min\\.css$/', $path) && !BackgroundImageManager::service()
->getCssMinifier()) {
$path = preg_replace('/\\.min\\.css$/', '.css', $path);
}
return $path;
}