You are here

public function NoBigPipeRouteAlterSubscriber::onRoutingRouteAlterSetNoBigPipe in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/big_pipe/src/EventSubscriber/NoBigPipeRouteAlterSubscriber.php \Drupal\big_pipe\EventSubscriber\NoBigPipeRouteAlterSubscriber::onRoutingRouteAlterSetNoBigPipe()
  2. 10 core/modules/big_pipe/src/EventSubscriber/NoBigPipeRouteAlterSubscriber.php \Drupal\big_pipe\EventSubscriber\NoBigPipeRouteAlterSubscriber::onRoutingRouteAlterSetNoBigPipe()

Alters select routes to have the '_no_big_pipe' option.

Parameters

\Drupal\Core\Routing\RouteBuildEvent $event: The event to process.

File

core/modules/big_pipe/src/EventSubscriber/NoBigPipeRouteAlterSubscriber.php, line 20

Class

NoBigPipeRouteAlterSubscriber
Sets the '_no_big_pipe' option on select routes.

Namespace

Drupal\big_pipe\EventSubscriber

Code

public function onRoutingRouteAlterSetNoBigPipe(RouteBuildEvent $event) {
  $no_big_pipe_routes = [
    // The batch system uses a <meta> refresh to work without JavaScript.
    'system.batch_page.html',
    // When a user would install the BigPipe module using a browser and with
    // JavaScript disabled, the first response contains the status messages
    // for installing a module, but then the BigPipe no-JS redirect occurs,
    // which then causes the user to not see those status messages.
    // @see https://www.drupal.org/node/2469431#comment-10901944
    'system.modules_list',
  ];
  $route_collection = $event
    ->getRouteCollection();
  foreach ($no_big_pipe_routes as $excluded_route) {
    if ($route = $route_collection
      ->get($excluded_route)) {
      $route
        ->setOption('_no_big_pipe', TRUE);
    }
  }
}