Chris@0: hasActiveTheme()) { Chris@0: return; Chris@0: } Chris@0: Chris@0: require_once __DIR__ . '/theme.inc'; Chris@0: require_once __DIR__ . '/common.inc'; Chris@0: require_once __DIR__ . '/unicode.inc'; Chris@0: require_once __DIR__ . '/file.inc'; Chris@0: require_once __DIR__ . '/module.inc'; Chris@0: require_once __DIR__ . '/database.inc'; Chris@0: Chris@0: // Install and update pages are treated differently to prevent theming overrides. Chris@0: if (defined('MAINTENANCE_MODE') && (MAINTENANCE_MODE == 'install' || MAINTENANCE_MODE == 'update')) { Chris@0: if (drupal_installation_attempted()) { Chris@0: $custom_theme = $GLOBALS['install_state']['theme']; Chris@0: } Chris@0: else { Chris@0: $custom_theme = Settings::get('maintenance_theme', 'seven'); Chris@0: } Chris@0: } Chris@0: else { Chris@0: // Use the maintenance theme if specified, otherwise attempt to use the Chris@0: // default site theme. Chris@0: try { Chris@0: $custom_theme = Settings::get('maintenance_theme', ''); Chris@0: if (!$custom_theme) { Chris@0: $config = \Drupal::config('system.theme'); Chris@0: $custom_theme = $config->get('default'); Chris@0: } Chris@0: } Chris@0: catch (\Exception $e) { Chris@0: // Whatever went wrong (often a database connection problem), we are Chris@0: // about to fall back to a sensible theme so there is no need for special Chris@0: // handling. Chris@0: } Chris@0: if (!$custom_theme) { Chris@0: // We have been unable to identify the configured theme, so fall back to Chris@0: // a safe default. Bartik is reasonably user friendly and fairly generic. Chris@0: $custom_theme = 'bartik'; Chris@0: } Chris@0: } Chris@0: Chris@0: $themes = \Drupal::service('theme_handler')->listInfo(); Chris@0: Chris@0: // If no themes are installed yet, or if the requested custom theme is not Chris@0: // installed, retrieve all available themes. Chris@0: /** @var \Drupal\Core\Theme\ThemeInitialization $theme_init */ Chris@0: $theme_init = \Drupal::service('theme.initialization'); Chris@0: $theme_handler = \Drupal::service('theme_handler'); Chris@0: if (empty($themes) || !isset($themes[$custom_theme])) { Chris@18: $themes = \Drupal::service('extension.list.theme')->getList(); Chris@0: $theme_handler->addTheme($themes[$custom_theme]); Chris@0: } Chris@0: Chris@0: // \Drupal\Core\Extension\ThemeHandlerInterface::listInfo() triggers a Chris@0: // \Drupal\Core\Extension\ModuleHandler::alter() in maintenance mode, but we Chris@0: // can't let themes alter the .info.yml data until we know a theme's base Chris@0: // themes. So don't set active theme until after Chris@0: // \Drupal\Core\Extension\ThemeHandlerInterface::listInfo() builds its cache. Chris@0: $theme = $custom_theme; Chris@0: Chris@0: // Find all our ancestor themes and put them in an array. Chris@0: // @todo This is just a workaround. Find a better way how to handle themes Chris@0: // on maintenance pages, see https://www.drupal.org/node/2322619. Chris@0: // This code is basically a duplicate of Chris@0: // \Drupal\Core\Theme\ThemeInitialization::getActiveThemeByName. Chris@0: $base_themes = []; Chris@0: $ancestor = $theme; Chris@0: while ($ancestor && isset($themes[$ancestor]->base_theme)) { Chris@0: $base_themes[] = $themes[$themes[$ancestor]->base_theme]; Chris@0: $ancestor = $themes[$ancestor]->base_theme; Chris@0: if ($ancestor) { Chris@0: // Ensure that the base theme is added and installed. Chris@0: $theme_handler->addTheme($themes[$ancestor]); Chris@0: } Chris@0: } Chris@0: \Drupal::theme()->setActiveTheme($theme_init->getActiveTheme($themes[$custom_theme], $base_themes)); Chris@0: // Prime the theme registry. Chris@0: Drupal::service('theme.registry'); Chris@0: } Chris@0: Chris@0: /** Chris@0: * Prepares variables for authorize.php operation report templates. Chris@0: * Chris@0: * This report displays the results of an operation run via authorize.php. Chris@0: * Chris@0: * Default template: authorize-report.html.twig. Chris@0: * Chris@0: * @param array $variables Chris@0: * An associative array containing: Chris@0: * - messages: An array of result messages. Chris@0: */ Chris@0: function template_preprocess_authorize_report(&$variables) { Chris@0: $messages = []; Chris@0: if (!empty($variables['messages'])) { Chris@0: foreach ($variables['messages'] as $heading => $logs) { Chris@0: $items = []; Chris@0: foreach ($logs as $number => $log_message) { Chris@0: if ($number === '#abort') { Chris@0: continue; Chris@0: } Chris@0: $class = 'authorize-results__' . ($log_message['success'] ? 'success' : 'failure'); Chris@0: $items[] = [ Chris@0: '#wrapper_attributes' => ['class' => [$class]], Chris@0: '#markup' => $log_message['message'], Chris@0: ]; Chris@0: } Chris@0: $messages[] = [ Chris@0: '#theme' => 'item_list', Chris@0: '#items' => $items, Chris@0: '#title' => $heading, Chris@0: ]; Chris@0: } Chris@0: } Chris@0: $variables['messages'] = $messages; Chris@0: }