You are here

function install_display_output in Drupal 9

Same name and namespace in other branches
  1. 8 core/includes/install.core.inc \install_display_output()
  2. 7 includes/install.core.inc \install_display_output()

Displays themed installer output and ends the page request.

Installation tasks should use #title to set the desired page title, but otherwise this function takes care of theming the overall page output during every step of the installation.

Parameters

$output: The content to display on the main part of the page.

$install_state: An array of information about the current installation state.

4 calls to install_display_output()
install_config_import_batch in core/includes/install.core.inc
Creates a batch for the config importer to process.
install_config_revert_install_changes in core/includes/install.core.inc
Reverts configuration if hook_install() implementations have made changes.
install_drupal in core/includes/install.core.inc
Installs Drupal either interactively or via an array of passed-in settings.
_drupal_log_error in core/includes/errors.inc
Logs a PHP error or exception and displays an error page in fatal cases.

File

core/includes/install.core.inc, line 1020
API functions for installing Drupal.

Code

function install_display_output($output, $install_state) {

  // Ensure the maintenance theme is initialized.
  // The regular initialization call in install_begin_request() may not be
  // reached in case of an early installer error.
  drupal_maintenance_theme();

  // Prevent install.php from being indexed when installed in a sub folder.
  // robots.txt rules are not read if the site is within domain.com/subfolder
  // resulting in /subfolder/install.php being found through search engines.
  // When settings.php is writable this can be used via an external database
  // leading a malicious user to gain php access to the server.
  $noindex_meta_tag = [
    '#tag' => 'meta',
    '#attributes' => [
      'name' => 'robots',
      'content' => 'noindex, nofollow',
    ],
  ];
  $output['#attached']['html_head'][] = [
    $noindex_meta_tag,
    'install_meta_robots',
  ];

  // Only show the task list if there is an active task; otherwise, the page
  // request has ended before tasks have even been started, so there is nothing
  // meaningful to show.
  $regions = [];
  if (isset($install_state['active_task'])) {

    // Let the theming function know when every step of the installation has
    // been completed.
    $active_task = $install_state['installation_finished'] ? NULL : $install_state['active_task'];
    $task_list = [
      '#theme' => 'maintenance_task_list',
      '#items' => install_tasks_to_display($install_state),
      '#active' => $active_task,
    ];
    $regions['sidebar_first'] = $task_list;
  }
  $bare_html_page_renderer = \Drupal::service('bare_html_page_renderer');
  $response = $bare_html_page_renderer
    ->renderBarePage($output, $output['#title'], 'install_page', $regions);
  $default_headers = [
    'Expires' => 'Sun, 19 Nov 1978 05:00:00 GMT',
    'Last-Modified' => gmdate(DATE_RFC1123, REQUEST_TIME),
    'Cache-Control' => 'no-cache, must-revalidate',
    'ETag' => '"' . REQUEST_TIME . '"',
  ];
  $response->headers
    ->add($default_headers);
  $response
    ->send();
  exit;
}