function PathProcessorSessions::processInbound

Same name in other branches
  1. 8.x-1.x stream_wrapper_example/src/PathProcessor/PathProcessorSessions.php \Drupal\stream_wrapper_example\PathProcessor\PathProcessorSessions::processInbound()
  2. 4.0.x modules/stream_wrapper_example/src/PathProcessor/PathProcessorSessions.php \Drupal\stream_wrapper_example\PathProcessor\PathProcessorSessions::processInbound()

Overrides InboundPathProcessorInterface::processInbound

File

modules/stream_wrapper_example/src/PathProcessor/PathProcessorSessions.php, line 20

Class

PathProcessorSessions
Defines a path processor to rewrite file URLs.

Namespace

Drupal\stream_wrapper_example\PathProcessor

Code

public function processInbound($path, Request $request) {
    if (strpos($path, '/examples/stream_wrapper_example/files/') === 0 && !$request->query
        ->has('file')) {
        $file_path = preg_replace('|^\\/examples\\/stream_wrapper_example\\/files\\/|', '', $path);
        $request->query
            ->set('file', $file_path);
        // We return the route we want to match.
        return '/examples/stream_wrapper_example/files';
    }
    return $path;
}