PathProcessorFiles.php
Same filename in other branches
Namespace
Drupal\system\PathProcessorFile
-
core/
modules/ system/ src/ PathProcessor/ PathProcessorFiles.php
View source
<?php
namespace Drupal\system\PathProcessor;
use Drupal\Core\PathProcessor\InboundPathProcessorInterface;
use Symfony\Component\HttpFoundation\Request;
/**
* Defines a path processor to rewrite file URLs.
*
* As the route system does not allow arbitrary amount of parameters convert
* the file path to a query parameter on the request.
*/
class PathProcessorFiles implements InboundPathProcessorInterface {
/**
* {@inheritdoc}
*/
public function processInbound($path, Request $request) {
if (str_starts_with($path, '/system/files/') && !$request->query
->has('file')) {
$file_path = preg_replace('|^\\/system\\/files\\/|', '', $path);
$request->query
->set('file', $file_path);
return '/system/files';
}
return $path;
}
}
Classes
Title | Deprecated | Summary |
---|---|---|
PathProcessorFiles | Defines a path processor to rewrite file URLs. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.