interface ThemeNegotiatorInterface in Zircon Profile 8.0
Same name and namespace in other branches
- 8 core/lib/Drupal/Core/Theme/ThemeNegotiatorInterface.php \Drupal\Core\Theme\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 user.services.yml for an example). The only method this service needs to implement is determineActiveTheme. Return the name of the theme, or NULL if other negotiators like the configured default one should kick in instead.
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
- interface \Drupal\Core\Theme\ThemeNegotiatorInterface
Expanded class hierarchy of ThemeNegotiatorInterface
All classes that implement ThemeNegotiatorInterface
8 files declare their use of ThemeNegotiatorInterface
- AdminDemoNegotiator.php in core/
modules/ block/ src/ Theme/ AdminDemoNegotiator.php - Contains \Drupal\block\Theme\AdminDemoNegotiator.
- AdminNegotiator.php in core/
modules/ user/ src/ Theme/ AdminNegotiator.php - Contains \Drupal\user\Theme\AdminNegotiator.
- BatchNegotiator.php in core/
modules/ system/ src/ Theme/ BatchNegotiator.php - Contains \Drupal\system\Theme\BatchNegotiator.
- CustomThemeNegotiator.php in core/
modules/ system/ tests/ modules/ theme_test/ src/ Theme/ CustomThemeNegotiator.php - Contains \Drupal\theme_test\Theme\CustomThemeNegotiator.
- DbUpdateNegotiator.php in core/
modules/ system/ src/ Theme/ DbUpdateNegotiator.php - Contains \Drupal\system\Theme\DbUpdateNegotiator.
File
- core/
lib/ Drupal/ Core/ Theme/ ThemeNegotiatorInterface.php, line 28 - Contains \Drupal\Core\Theme\ThemeNegotiatorInterface.
Namespace
Drupal\Core\ThemeView source
interface ThemeNegotiatorInterface {
/**
* Whether this theme negotiator should be used to set the theme.
*
* @param \Drupal\Core\Routing\RouteMatchInterface $route_match
* The current route match object.
*
* @return bool
* TRUE if this negotiator should be used or FALSE to let other negotiators
* decide.
*/
public function applies(RouteMatchInterface $route_match);
/**
* Determine the active theme for the request.
*
* @param \Drupal\Core\Routing\RouteMatchInterface $route_match
* The current route match object.
*
* @return string|null
* Returns the active theme name, else return NULL.
*/
public function determineActiveTheme(RouteMatchInterface $route_match);
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ThemeNegotiatorInterface:: |
public | function | Whether this theme negotiator should be used to set the theme. | 10 |
ThemeNegotiatorInterface:: |
public | function | Determine the active theme for the request. | 10 |