You are here

public function BatchController::batchPage in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/system/src/Controller/BatchController.php \Drupal\system\Controller\BatchController::batchPage()
  2. 9 core/modules/system/src/Controller/BatchController.php \Drupal\system\Controller\BatchController::batchPage()

Returns a system batch page.

Parameters

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

Return value

\Symfony\Component\HttpFoundation\Response|array A \Symfony\Component\HttpFoundation\Response object or render array.

Throws

\Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException

1 string reference to 'BatchController::batchPage'
system.routing.yml in core/modules/system/system.routing.yml
core/modules/system/system.routing.yml

File

core/modules/system/src/Controller/BatchController.php, line 53

Class

BatchController
Controller routines for batch routes.

Namespace

Drupal\system\Controller

Code

public function batchPage(Request $request) {
  require_once $this->root . '/core/includes/batch.inc';
  $output = _batch_page($request);
  if ($output === FALSE) {
    throw new AccessDeniedHttpException();
  }
  elseif ($output instanceof Response) {
    return $output;
  }
  elseif (isset($output)) {
    $title = $output['#title'] ?? NULL;
    $page = [
      '#type' => 'page',
      '#title' => $title,
      '#show_messages' => FALSE,
      'content' => $output,
    ];

    // Also inject title as a page header (if available).
    if ($title) {
      $page['header'] = [
        '#type' => 'page_title',
        '#title' => $title,
      ];
    }
    return $page;
  }
}