You are here

public function DbUpdateController::handle in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 core/modules/system/src/Controller/DbUpdateController.php \Drupal\system\Controller\DbUpdateController::handle()

Returns a database update page.

Parameters

string $op: The update operation to perform. Can be any of the below:

  • info
  • selection
  • run
  • results

\Symfony\Component\HttpFoundation\Request $request: The current request object.

Return value

\Symfony\Component\HttpFoundation\Response A response object object.

File

core/modules/system/src/Controller/DbUpdateController.php, line 147
Contains \Drupal\system\Controller\DbUpdateController.

Class

DbUpdateController
Controller routines for database update routes.

Namespace

Drupal\system\Controller

Code

public function handle($op, Request $request) {
  require_once $this->root . '/core/includes/install.inc';
  require_once $this->root . '/core/includes/update.inc';
  drupal_load_updates();
  update_fix_compatibility();
  if ($request->query
    ->get('continue')) {
    $_SESSION['update_ignore_warnings'] = TRUE;
  }
  $regions = array();
  $requirements = update_check_requirements();
  $severity = drupal_requirements_severity($requirements);
  if ($severity == REQUIREMENT_ERROR || $severity == REQUIREMENT_WARNING && empty($_SESSION['update_ignore_warnings'])) {
    $regions['sidebar_first'] = $this
      ->updateTasksList('requirements');
    $output = $this
      ->requirements($severity, $requirements, $request);
  }
  else {
    switch ($op) {
      case 'selection':
        $regions['sidebar_first'] = $this
          ->updateTasksList('selection');
        $output = $this
          ->selection($request);
        break;
      case 'run':
        $regions['sidebar_first'] = $this
          ->updateTasksList('run');
        $output = $this
          ->triggerBatch($request);
        break;
      case 'info':
        $regions['sidebar_first'] = $this
          ->updateTasksList('info');
        $output = $this
          ->info($request);
        break;
      case 'results':
        $regions['sidebar_first'] = $this
          ->updateTasksList('results');
        $output = $this
          ->results($request);
        break;

      // Regular batch ops : defer to batch processing API.
      default:
        require_once $this->root . '/core/includes/batch.inc';
        $regions['sidebar_first'] = $this
          ->updateTasksList('run');
        $output = _batch_page($request);
        break;
    }
  }
  if ($output instanceof Response) {
    return $output;
  }
  $title = isset($output['#title']) ? $output['#title'] : $this
    ->t('Drupal database update');
  return $this->bareHtmlPageRenderer
    ->renderBarePage($output, $title, 'maintenance_page', $regions);
}