protected function WebformThemeNegotiator::getActiveTheme in Webform 6.x
Same name and namespace in other branches
- 8.5 src/Theme/WebformThemeNegotiator.php \Drupal\webform\Theme\WebformThemeNegotiator::getActiveTheme()
Determine the active theme for the current route.
Parameters
\Drupal\Core\Routing\RouteMatchInterface $route_match: The current route match.
Return value
string The active theme or an empty string.
2 calls to WebformThemeNegotiator::getActiveTheme()
- WebformThemeNegotiator::applies in src/
Theme/ WebformThemeNegotiator.php - Whether this theme negotiator should be used to set the theme.
- WebformThemeNegotiator::determineActiveTheme in src/
Theme/ WebformThemeNegotiator.php - Determine the active theme for the request.
File
- src/
Theme/ WebformThemeNegotiator.php, line 77
Class
- WebformThemeNegotiator
- Sets the admin theme on a webform that does not have a public canonical URL.
Namespace
Drupal\webform\ThemeCode
protected function getActiveTheme(RouteMatchInterface $route_match) {
$route_name = $route_match
->getRouteName();
if (strpos($route_name, 'webform') === FALSE) {
return '';
}
$webform = $this->requestHandler
->getCurrentWebform();
if (empty($webform)) {
return '';
}
$is_webform_route = in_array($route_name, [
'entity.webform.canonical',
'entity.webform.test_form',
'entity.webform.confirmation',
'entity.node.webform.test_form',
]);
$is_user_submission_route = strpos($route_name, 'entity.webform.user.') === 0;
// If webform route and page is disabled, apply admin theme to
// the webform routes.
if ($is_webform_route && !$webform
->getSetting('page')) {
return $this->user
->hasPermission('view the administration theme') ? $this->configFactory
->get('system.theme')
->get('admin') : '';
}
// If webform and user submission routes apply custom page theme to
// the webform routes.
if (($is_webform_route || $is_user_submission_route) && $webform
->getSetting('page_theme_name')) {
return $webform
->getSetting('page_theme_name');
}
return '';
}