class PathProcessorFiles

Same name in other branches
  1. 9 core/modules/system/src/PathProcessor/PathProcessorFiles.php \Drupal\system\PathProcessor\PathProcessorFiles
  2. 8.9.x core/modules/system/src/PathProcessor/PathProcessorFiles.php \Drupal\system\PathProcessor\PathProcessorFiles
  3. 11.x core/modules/system/src/PathProcessor/PathProcessorFiles.php \Drupal\system\PathProcessor\PathProcessorFiles

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.

Hierarchy

  • class \Drupal\system\PathProcessor\PathProcessorFiles implements \Drupal\Core\PathProcessor\InboundPathProcessorInterface

Expanded class hierarchy of PathProcessorFiles

1 string reference to 'PathProcessorFiles'
system.services.yml in core/modules/system/system.services.yml
core/modules/system/system.services.yml
1 service uses PathProcessorFiles
path_processor.files in core/modules/system/system.services.yml
Drupal\system\PathProcessor\PathProcessorFiles

File

core/modules/system/src/PathProcessor/PathProcessorFiles.php, line 14

Namespace

Drupal\system\PathProcessor
View source
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;
    }

}

Members

Title Sort descending Modifiers Object type Summary
PathProcessorFiles::processInbound public function

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.