You are here

public function FormModeThemeNegociator::determineActiveTheme in Form mode manager 8.2

Determine the active theme from the route or configuration.

Parameters

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

Return value

string The name of the theme

Overrides ThemeNegotiatorInterface::determineActiveTheme

File

modules/form_mode_theme_switcher/src/Theme/FormModeThemeNegociator.php, line 107

Class

FormModeThemeNegociator
Class FormModeThemeNegociator.

Namespace

Drupal\form_mode_manager_theme_switcher\Theme

Code

public function determineActiveTheme(RouteMatchInterface $route_match) {
  $route_object = $route_match
    ->getRouteObject();
  $route_form_mode_theme = $route_object
    ->getOption('form_mode_theme');

  // Priority to route 'form_mode_theme' parametter theme.
  if (isset($route_form_mode_theme)) {
    return $route_form_mode_theme;
  }
  $form_mode_id = str_replace('.', '_', $route_object
    ->getDefault('_entity_form'));
  $theme_type = $this->formModeThemeSwitcherConfig
    ->get("type.{$form_mode_id}");

  // If theme set from settings is set to 'default admin theme'.
  if ($this
    ->isAdminTheme($route_match, $theme_type)) {
    return $this->systemThemeConfig
      ->get('admin');
  }

  // If theme set from settings is set to 'default theme (front)'.
  if (!$this
    ->isCustomTheme($theme_type)) {
    return $this->systemThemeConfig
      ->get($theme_type);
  }
  elseif ($this
    ->isCustomTheme($theme_type)) {
    return $this->formModeThemeSwitcherConfig
      ->get("form_mode.{$form_mode_id}");
  }
  return $this->theme;
}