LocalPathProcessor.php in Flysystem 2.0.x
File
src/PathProcessor/LocalPathProcessor.php
View source
<?php
namespace Drupal\flysystem\PathProcessor;
use Drupal\Core\PathProcessor\InboundPathProcessorInterface;
use Drupal\Core\Site\Settings;
use Symfony\Component\HttpFoundation\Request;
class LocalPathProcessor implements InboundPathProcessorInterface {
protected $root;
protected $scheme;
public function __construct($scheme) {
$this->scheme = $scheme;
$settings = Settings::get('flysystem', []);
$this->root = $settings[$scheme]['config']['root'];
}
public function processInbound($path, Request $request) {
if (strpos($path, '/' . $this->root . '/') !== 0) {
return $path;
}
$rest = substr($path, strlen($this->root) + 2);
if (strpos($rest, 'styles/') === 0 && substr_count($rest, '/') >= 3) {
list(, $image_style, $scheme, $file) = explode('/', $rest, 4);
$request->query
->set('file', $file);
return '/' . $this->root . '/styles/' . $image_style . '/' . $scheme;
}
$request->query
->set('file', $rest);
return '/' . $this->root;
}
}
Classes
Name |
Description |
LocalPathProcessor |
Defines a path processor to serve public files directly for the local
adapter. |