You are here

public function ThemeNegotiatorWrapper::determineActiveTheme in Devel 8.3

Same name and namespace in other branches
  1. 8 webprofiler/src/Theme/ThemeNegotiatorWrapper.php \Drupal\webprofiler\Theme\ThemeNegotiatorWrapper::determineActiveTheme()
  2. 8.2 webprofiler/src/Theme/ThemeNegotiatorWrapper.php \Drupal\webprofiler\Theme\ThemeNegotiatorWrapper::determineActiveTheme()
  3. 4.x webprofiler/src/Theme/ThemeNegotiatorWrapper.php \Drupal\webprofiler\Theme\ThemeNegotiatorWrapper::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 ThemeNegotiator::determineActiveTheme

File

webprofiler/src/Theme/ThemeNegotiatorWrapper.php, line 21

Class

ThemeNegotiatorWrapper
Class ThemeNegotiatorWrapper.

Namespace

Drupal\webprofiler\Theme

Code

public function determineActiveTheme(RouteMatchInterface $route_match) {

  // This method has changed in Drupal 8.4.x, to maintain compatibility with
  // Drupal 8.3.x we check the existence or not of the classResolver
  // property.
  // TODO: remove this logic when we decide to drop Drupal 8.3.x support.
  if (property_exists($this, 'classResolver')) {
    $classResolver = $this->classResolver;
    $negotiators = $this->negotiators;
  }
  else {
    $classResolver = \Drupal::classResolver();
    $negotiators = $this
      ->getSortedNegotiators();
  }
  foreach ($negotiators as $negotiator_id) {
    if (property_exists($this, 'classResolver')) {
      $negotiator = $classResolver
        ->getInstanceFromDefinition($negotiator_id);
    }
    else {
      $negotiator = $negotiator_id;
    }
    if ($negotiator
      ->applies($route_match)) {
      $theme = $negotiator
        ->determineActiveTheme($route_match);
      if ($theme !== NULL && $this->themeAccess
        ->checkAccess($theme)) {
        $this->negotiator = $negotiator;
        return $theme;
      }
    }
  }
}