You are here

public function AmpNegotiator::applies in Accelerated Mobile Pages (AMP) 8

Same name and namespace in other branches
  1. 8.3 src/Theme/AmpNegotiator.php \Drupal\amp\Theme\AmpNegotiator::applies()
  2. 8.2 src/Theme/AmpNegotiator.php \Drupal\amp\Theme\AmpNegotiator::applies()

Whether this theme negotiator should be used to set the theme.

Parameters

\Drupal\Core\Routing\RouteMatchInterface $route_match: The current route match object.

Return value

bool TRUE if this negotiator should be used or FALSE to let other negotiators decide.

Overrides ThemeNegotiatorInterface::applies

File

src/Theme/AmpNegotiator.php, line 50
Contains \Drupal\amp\Theme\AmpNegotiator.

Class

AmpNegotiator
Sets the active theme on amp pages.

Namespace

Drupal\amp\Theme

Code

public function applies(RouteMatchInterface $route_match) {
  $is_amp_route = $this->ampContext
    ->isAmpRoute($route_match
    ->getRouteObject());
  if ($is_amp_route) {

    // Disable big pipe on AMP pages.
    // @todo Rely on https://www.drupal.org/node/2729441 instead, when it is
    //   resolved.
    $route_match
      ->getRouteObject()
      ->setOption('_no_big_pipe', TRUE);
  }
  return $is_amp_route;
}