class ContextualLinksNegotiator

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

Hierarchy

Expanded class hierarchy of ContextualLinksNegotiator

1 string reference to 'ContextualLinksNegotiator'
contextual.services.yml in core/modules/contextual/contextual.services.yml
core/modules/contextual/contextual.services.yml
1 service uses ContextualLinksNegotiator
theme.negotiator.contextual_links in core/modules/contextual/contextual.services.yml
Drupal\contextual\Theme\ContextualLinksNegotiator

File

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

Namespace

Drupal\contextual\Theme
View source
final class ContextualLinksNegotiator implements ThemeNegotiatorInterface {
  public function __construct(protected readonly RouteMatchInterface $route_match, protected readonly RequestStack $requestStack, protected readonly ThemeHandlerInterface $themeHandler, protected readonly ConfigFactoryInterface $configFactory) {
  }
  public function applies(RouteMatchInterface $route_match) : bool {
    return $route_match->getRouteName() === 'contextual.render';
  }
  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');
  }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title
ContextualLinksNegotiator::applies public function Whether this theme negotiator should be used to set the theme. Overrides ThemeNegotiatorInterface::applies
ContextualLinksNegotiator::determineActiveTheme public function Determine the active theme for the request. Overrides ThemeNegotiatorInterface::determineActiveTheme
ContextualLinksNegotiator::__construct public function

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