PathProcessorSessions.php in Examples for Developers 3.x
File
modules/stream_wrapper_example/src/PathProcessor/PathProcessorSessions.php
View source
<?php
namespace Drupal\stream_wrapper_example\PathProcessor;
use Drupal\Core\PathProcessor\InboundPathProcessorInterface;
use Symfony\Component\HttpFoundation\Request;
class PathProcessorSessions implements InboundPathProcessorInterface {
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);
return '/examples/stream_wrapper_example/files';
}
return $path;
}
}