1<?php
2
3namespace Drupal\Core\Theme;
4
5use Drupal\Core\Routing\RouteMatchInterface;
6
7/**
8 * Defines an interface for classes which determine the active theme.
9 *
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.
13 *
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.
21 */
22interface ThemeNegotiatorInterface {
23
24  /**
25   * Whether this theme negotiator should be used to set the theme.
26   *
27   * @param \Drupal\Core\Routing\RouteMatchInterface $route_match
28   *   The current route match object.
29   *
30   * @return bool
31   *   TRUE if this negotiator should be used or FALSE to let other negotiators
32   *   decide.
33   */
34  public function applies(RouteMatchInterface $route_match);
35
36  /**
37   * Determine the active theme for the request.
38   *
39   * @param \Drupal\Core\Routing\RouteMatchInterface $route_match
40   *   The current route match object.
41   *
42   * @return string|null
43   *   The name of the theme, or NULL if other negotiators, like the configured
44   *   default one, should be used instead.
45   */
46  public function determineActiveTheme(RouteMatchInterface $route_match);
47
48}
49