You are here

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

Same name and namespace in other branches
  1. 8.3 src/Theme/AmpNegotiator.php \Drupal\amp\Theme\AmpNegotiator::applies()
  2. 8 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 46

Class

AmpNegotiator
Sets the active theme on amp pages.

Namespace

Drupal\amp\Theme

Code

public function applies(RouteMatchInterface $routeMatch) {

  // See if this route and object are AMP, without checking the active theme.
  $is_amp_route = $this->ampContext
    ->isAmpRoute($routeMatch, NULL, FALSE);
  if ($is_amp_route) {

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