3 namespace Drupal\system\PathProcessor;
5 use Drupal\Core\PathProcessor\InboundPathProcessorInterface;
6 use Symfony\Component\HttpFoundation\Request;
9 * Defines a path processor to rewrite file URLs.
11 * As the route system does not allow arbitrary amount of parameters convert
12 * the file path to a query parameter on the request.
14 class PathProcessorFiles implements InboundPathProcessorInterface {
19 public function processInbound($path, Request $request) {
20 if (strpos($path, '/system/files/') === 0 && !$request->query->has('file')) {
21 $file_path = preg_replace('|^\/system\/files\/|', '', $path);
22 $request->query->set('file', $file_path);
23 return '/system/files';