3 namespace Drupal\big_pipe\EventSubscriber;
5 use Symfony\Component\EventDispatcher\EventSubscriberInterface;
6 use Drupal\Core\Routing\RoutingEvents;
7 use Drupal\Core\Routing\RouteBuildEvent;
10 * Sets the '_no_big_pipe' option on select routes.
12 class NoBigPipeRouteAlterSubscriber implements EventSubscriberInterface {
15 * Alters select routes to have the '_no_big_pipe' option.
17 * @param \Drupal\Core\Routing\RouteBuildEvent $event
18 * The event to process.
20 public function onRoutingRouteAlterSetNoBigPipe(RouteBuildEvent $event) {
21 $no_big_pipe_routes = [
22 // The batch system uses a <meta> refresh to work without JavaScript.
23 'system.batch_page.html',
24 // When a user would install the BigPipe module using a browser and with
25 // JavaScript disabled, the first response contains the status messages
26 // for installing a module, but then the BigPipe no-JS redirect occurs,
27 // which then causes the user to not see those status messages.
28 // @see https://www.drupal.org/node/2469431#comment-10901944
29 'system.modules_list',
32 $route_collection = $event->getRouteCollection();
33 foreach ($no_big_pipe_routes as $excluded_route) {
34 if ($route = $route_collection->get($excluded_route)) {
35 $route->setOption('_no_big_pipe', TRUE);
43 public static function getSubscribedEvents() {
44 $events[RoutingEvents::ALTER][] = ['onRoutingRouteAlterSetNoBigPipe'];