ImageStyleRoutes.php in Drupal 8
File
core/modules/image/src/Routing/ImageStyleRoutes.php
View source
<?php
namespace Drupal\image\Routing;
use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
use Drupal\Core\StreamWrapper\StreamWrapperManagerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\Routing\Route;
class ImageStyleRoutes implements ContainerInjectionInterface {
protected $streamWrapperManager;
public function __construct(StreamWrapperManagerInterface $stream_wrapper_manager) {
$this->streamWrapperManager = $stream_wrapper_manager;
}
public static function create(ContainerInterface $container) {
return new static($container
->get('stream_wrapper_manager'));
}
public function routes() {
$routes = [];
$directory_path = $this->streamWrapperManager
->getViaScheme('public')
->getDirectoryPath();
$routes['image.style_public'] = new Route('/' . $directory_path . '/styles/{image_style}/{scheme}', [
'_controller' => 'Drupal\\image\\Controller\\ImageStyleDownloadController::deliver',
], [
'_access' => 'TRUE',
]);
return $routes;
}
}
Classes
Name |
Description |
ImageStyleRoutes |
Defines a route subscriber to register a url for serving image styles. |