public function ThemeSwitcherNegotiator::applies in Context 8
Same name and namespace in other branches
- 8.4 src/Theme/ThemeSwitcherNegotiator.php \Drupal\context\Theme\ThemeSwitcherNegotiator::applies()
Whether this theme negotiator should be used to set the theme.
Parameters
\Drupal\Core\Routing\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.
Overrides ThemeNegotiatorInterface::applies
File
- src/
Theme/ ThemeSwitcherNegotiator.php, line 42
Class
- ThemeSwitcherNegotiator
- Context Theme Switcher Negotiator.
Namespace
Drupal\context\ThemeCode
public function applies(RouteMatchInterface $route_match) {
// If there is no Theme reaction set, do not try to get active reactions,
// since this causes infinite loop.
$theme_reaction = FALSE;
foreach ($this->contextManager
->getContexts() as $context) {
foreach ($context
->getReactions() as $reaction) {
if ($reaction instanceof Theme) {
$theme_reaction = TRUE;
break;
}
}
}
if ($theme_reaction) {
foreach ($this->contextManager
->getActiveReactions('theme') as $theme_reaction) {
$configuration = $theme_reaction
->getConfiguration();
$this->theme = $configuration['theme'];
return TRUE;
}
}
return FALSE;
}