You are here

public function BackgroundImageRoutes::routes in Background Image 2.0.x

Same name and namespace in other branches
  1. 8 src/Routing/BackgroundImageRoutes.php \Drupal\background_image\Routing\BackgroundImageRoutes::routes()
  2. 2.x src/Routing/BackgroundImageRoutes.php \Drupal\background_image\Routing\BackgroundImageRoutes::routes()

Returns an array of route objects.

Return value

\Symfony\Component\Routing\Route[] An array of route objects.

1 string reference to 'BackgroundImageRoutes::routes'
background_image.routing.yml in ./background_image.routing.yml
background_image.routing.yml

File

src/Routing/BackgroundImageRoutes.php, line 47

Class

BackgroundImageRoutes
Defines a route subscriber to register a url for serving background image CSS.

Namespace

Drupal\background_image\Routing

Code

public function routes() {
  $routes = [];

  // Generate background image CSS files. If clean URLs are disabled the
  // files will always be served through the menu system. If clean URLs are
  // enabled and the file already exists, PHP will be bypassed.
  $directory_path = $this->streamWrapperManager
    ->getViaScheme('public')
    ->getDirectoryPath();
  $routes['background_image.css'] = new Route('/' . $directory_path . '/background_image/css/{background_image}/{scheme}/{file}', [
    '_controller' => 'Drupal\\background_image\\Controller\\BackgroundImageCssController::deliver',
  ], [
    '_access' => 'TRUE',
  ]);
  return $routes;
}