3 namespace Drupal\Core\Theme;
5 use Drupal\Core\Routing\RouteMatchInterface;
8 * Defines an interface for classes which determine the active theme.
10 * To set the active theme, create a new service tagged with 'theme_negotiator'
11 * (see the theme.negotiator.admin_theme service in user.services.yml for an
12 * example). Your service class needs to implement this interface.
14 * If you are setting a theme which is closely tied to the functionality of a
15 * particular page or set of pages (such that the page might not function
16 * correctly if a different theme is used), make sure to set the priority on
17 * the service to a high number so that it is not accidentally overridden by
18 * other theme negotiators. By convention, a priority of "1000" is used in
19 * these cases; see \Drupal\Core\Theme\AjaxBasePageNegotiator and
20 * core.services.yml for an example.
22 interface ThemeNegotiatorInterface {
25 * Whether this theme negotiator should be used to set the theme.
27 * @param \Drupal\Core\Routing\RouteMatchInterface $route_match
28 * The current route match object.
31 * TRUE if this negotiator should be used or FALSE to let other negotiators
34 public function applies(RouteMatchInterface $route_match);
37 * Determine the active theme for the request.
39 * @param \Drupal\Core\Routing\RouteMatchInterface $route_match
40 * The current route match object.
43 * The name of the theme, or NULL if other negotiators, like the configured
44 * default one, should be used instead.
46 public function determineActiveTheme(RouteMatchInterface $route_match);