function ContextualLinksNegotiator::determineActiveTheme

Determine the active theme for the request.

Parameters

\Drupal\Core\Routing\RouteMatchInterface $route_match: The current route match object.

Return value

string|null The name of the theme, or NULL if other negotiators, like the configured default one, should be used instead.

Overrides ThemeNegotiatorInterface::determineActiveTheme

File

core/modules/contextual/src/Theme/ContextualLinksNegotiator.php, line 27

Class

ContextualLinksNegotiator
Set the theme according to the parameter passed to the controller.

Namespace

Drupal\contextual\Theme

Code

public function determineActiveTheme(RouteMatchInterface $route_match) : string {
  $request = $this->requestStack
    ->getCurrentRequest();
  $theme = $request?->query->get('theme', '') ?? '';
  if ($this->themeHandler
    ->themeExists($theme)) {
    return $theme;
  }
  return $this->configFactory
    ->get('system.theme')
    ->get('default');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.