class ThemeNegotiator implements ThemeNegotiatorInterface (View source)

Provides a class which determines the active theme of the page.

It therefore uses ThemeNegotiatorInterface objects which are passed in using the 'theme_negotiator' tag.

Properties

protected string[] $negotiators

Holds an array of theme negotiator IDs, sorted by priority.

protected ThemeAccessCheck $themeAccess

The access checker for themes.

protected ClassResolverInterface $classResolver

The class resolver.

Methods

__construct(ThemeAccessCheck $theme_access, ClassResolverInterface $class_resolver, array $negotiators)

Constructs a new ThemeNegotiator.

bool
applies(RouteMatchInterface $route_match)

Whether this theme negotiator should be used to set the theme.

string|null
determineActiveTheme(RouteMatchInterface $route_match)

Determine the active theme for the request.

Details

__construct(ThemeAccessCheck $theme_access, ClassResolverInterface $class_resolver, array $negotiators)

Constructs a new ThemeNegotiator.

Parameters

ThemeAccessCheck $theme_access

The access checker for themes.

ClassResolverInterface $class_resolver

The class resolver.

array $negotiators

An array of negotiator IDs.

bool applies(RouteMatchInterface $route_match)

Whether this theme negotiator should be used to set the theme.

Parameters

RouteMatchInterface $route_match

The current route match object.

Return Value

bool

TRUE if this negotiator should be used or FALSE to let other negotiators decide.

string|null determineActiveTheme(RouteMatchInterface $route_match)

Determine the active theme for the request.

Parameters

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.