W3cubDocs

/Drupal 8

interface ThemeNegotiatorInterface

Defines an interface for classes which determine the active theme.

To set the active theme, create a new service tagged with 'theme_negotiator' (see the theme.negotiator.admin_theme service in user.services.yml for an example). Your service class needs to implement this interface.

If you are setting a theme which is closely tied to the functionality of a particular page or set of pages (such that the page might not function correctly if a different theme is used), make sure to set the priority on the service to a high number so that it is not accidentally overridden by other theme negotiators. By convention, a priority of "1000" is used in these cases; see \Drupal\Core\Theme\AjaxBasePageNegotiator and core.services.yml for an example.

Hierarchy

File

core/lib/Drupal/Core/Theme/ThemeNegotiatorInterface.php, line 22

Namespace

Drupal\Core\Theme

Members

Name Modifiers Type Description
ThemeNegotiatorInterface::applies public function Whether this theme negotiator should be used to set the theme.
ThemeNegotiatorInterface::determineActiveTheme public function Determine the active theme for the request.

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Theme!ThemeNegotiatorInterface.php/interface/ThemeNegotiatorInterface/8.1.x