You are here

public function DefaultController::styleswitcherCss in Style Switcher 8.2

Same name and namespace in other branches
  1. 3.0.x src/Controller/DefaultController.php \Drupal\styleswitcher\Controller\DefaultController::styleswitcherCss()

Redirects to CSS file of currently active style.

Parameters

string $theme: Name of the theme to find the active style for. This argument is needed to know what the page user came from and what theme was used there.

Return value

\Symfony\Component\HttpFoundation\Response Response object.

1 string reference to 'DefaultController::styleswitcherCss'
styleswitcher.routing.yml in ./styleswitcher.routing.yml
styleswitcher.routing.yml

File

src/Controller/DefaultController.php, line 84

Class

DefaultController
Default controller for the styleswitcher module.

Namespace

Drupal\styleswitcher\Controller

Code

public function styleswitcherCss($theme) {

  // Prevent resource incorrect interpretation.
  $headers = [
    'Content-Type' => 'text/css',
  ];
  $path = $this
    ->activeStylePath($theme);
  if (isset($path)) {
    return new TrustedRedirectResponse(file_create_url($path), 302, $headers);
  }
  else {
    return new Response('', 200, $headers);
  }
}