class ImageStyleRoutes
Same name in other branches
- 9 core/modules/image/src/Routing/ImageStyleRoutes.php \Drupal\image\Routing\ImageStyleRoutes
- 8.9.x core/modules/image/src/Routing/ImageStyleRoutes.php \Drupal\image\Routing\ImageStyleRoutes
- 10 core/modules/image/src/Routing/ImageStyleRoutes.php \Drupal\image\Routing\ImageStyleRoutes
Defines a route subscriber to register a URL for serving image styles.
Hierarchy
- class \Drupal\image\Routing\ImageStyleRoutes implements \Drupal\Core\DependencyInjection\ContainerInjectionInterface
Expanded class hierarchy of ImageStyleRoutes
File
-
core/
modules/ image/ src/ Routing/ ImageStyleRoutes.php, line 13
Namespace
Drupal\image\RoutingView source
class ImageStyleRoutes implements ContainerInjectionInterface {
/**
* The stream wrapper manager service.
*
* @var \Drupal\Core\StreamWrapper\StreamWrapperManagerInterface
*/
protected $streamWrapperManager;
/**
* Constructs a new ImageStyleRoutes object.
*
* @param \Drupal\Core\StreamWrapper\StreamWrapperManagerInterface $stream_wrapper_manager
* The stream wrapper manager service.
*/
public function __construct(StreamWrapperManagerInterface $stream_wrapper_manager) {
$this->streamWrapperManager = $stream_wrapper_manager;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
return new static($container->get('stream_wrapper_manager'));
}
/**
* Returns an array of route objects.
*
* @return \Symfony\Component\Routing\Route[]
* An array of route objects.
*/
public function routes() {
$routes = [];
// Generate image derivatives of publicly available files. If clean URLs are
// disabled image derivatives will always be served through the menu system.
// If clean URLs are enabled and the image derivative already exists, PHP
// will be bypassed.
$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',
'required_derivative_scheme' => 'public',
], [
'_access' => 'TRUE',
]);
return $routes;
}
}
Members
Title Sort descending | Modifiers | Object type | Summary | Overriden Title |
---|---|---|---|---|
ImageStyleRoutes::$streamWrapperManager | protected | property | The stream wrapper manager service. | |
ImageStyleRoutes::create | public static | function | Overrides ContainerInjectionInterface::create | |
ImageStyleRoutes::routes | public | function | Returns an array of route objects. | |
ImageStyleRoutes::__construct | public | function | Constructs a new ImageStyleRoutes object. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.