Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. AssetRoutes.php

function AssetRoutes::routes

Returns an array of route objects.

Return value

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

1 string reference to 'AssetRoutes::routes'
system.routing.yml in core/modules/system/system.routing.yml
core/modules/system/system.routing.yml

File

core/modules/system/src/Routing/AssetRoutes.php, line 40

Class

AssetRoutes
Defines a routes' callback to register a URL for serving assets.

Namespace

Drupal\system\Routing

Code

public function routes() : array {
    $routes = [];
    // Generate assets. If clean URLs are disabled image derivatives will always
    // be served through the routing system. If clean URLs are enabled and the
    // image derivative already exists, PHP will be bypassed.
    $directory_path = $this->streamWrapperManager
        ->getViaScheme('assets')
        ->getDirectoryPath();
    $routes['system.css_asset'] = new Route('/' . $directory_path . '/css/{file_name}', [
        '_controller' => 'Drupal\\system\\Controller\\CssAssetController::deliver',
    ], [
        '_access' => 'TRUE',
    ]);
    $routes['system.js_asset'] = new Route('/' . $directory_path . '/js/{file_name}', [
        '_controller' => 'Drupal\\system\\Controller\\JsAssetController::deliver',
    ], [
        '_access' => 'TRUE',
    ]);
    return $routes;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal