BatchController.php in Drupal 8
File
core/modules/system/src/Controller/BatchController.php
View source
<?php
namespace Drupal\system\Controller;
use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
class BatchController implements ContainerInjectionInterface {
protected $root;
public function __construct($root) {
$this->root = $root;
}
public static function create(ContainerInterface $container) {
return new static($container
->get('app.root'));
}
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 = isset($output['#title']) ? $output['#title'] : NULL;
$page = [
'#type' => 'page',
'#title' => $title,
'#show_messages' => FALSE,
'content' => $output,
];
if ($title) {
$page['header'] = [
'#type' => 'page_title',
'#title' => $title,
];
}
return $page;
}
}
public function batchPageTitle() {
$current_set = _batch_current_set();
return !empty($current_set['title']) ? $current_set['title'] : '';
}
}