You are here

class BatchController in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/system/src/Controller/BatchController.php \Drupal\system\Controller\BatchController

Controller routines for batch routes.

Hierarchy

Expanded class hierarchy of BatchController

File

core/modules/system/src/Controller/BatchController.php, line 19
Contains \Drupal\system\Controller\BatchController.

Namespace

Drupal\system\Controller
View source
class BatchController implements ContainerInjectionInterface {

  /**
   * The app root.
   *
   * @var string
   */
  protected $root;

  /**
   * Constructs a new BatchController.
   *
   * @param string $root
   *   The app root.
   */
  public function __construct($root) {
    $this->root = $root;
  }

  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container) {
    return new static($container
      ->get('app.root'));
  }

  /**
   * Returns a system batch page.
   *
   * @param \Symfony\Component\HttpFoundation\Request $request
   *   The current request object.
   *
   * @return \Symfony\Component\HttpFoundation\Response|array
   *   A \Symfony\Component\HttpFoundation\Response object or render array.
   *
   * @throws \Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException
   */
  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)) {
      $page = [
        '#type' => 'page',
        '#show_messages' => FALSE,
        'content' => $output,
      ];
      return $page;
    }
  }

  /**
   * The _title_callback for the system.batch_page.normal route.
   *
   * @return string
   *   The page title.
   */
  public function batchPageTitle() {
    $current_set = _batch_current_set();
    return !empty($current_set['title']) ? $current_set['title'] : '';
  }

}

Members

Namesort descending Modifiers Type Description Overrides
BatchController::$root protected property The app root.
BatchController::batchPage public function Returns a system batch page.
BatchController::batchPageTitle public function The _title_callback for the system.batch_page.normal route.
BatchController::create public static function Instantiates a new instance of this class. Overrides ContainerInjectionInterface::create
BatchController::__construct public function Constructs a new BatchController.