function RoutePreloader::isGetAndHtmlRoute

Same name in other branches
  1. 9 core/lib/Drupal/Core/Routing/RoutePreloader.php \Drupal\Core\Routing\RoutePreloader::isGetAndHtmlRoute()
  2. 8.9.x core/lib/Drupal/Core/Routing/RoutePreloader.php \Drupal\Core\Routing\RoutePreloader::isGetAndHtmlRoute()
  3. 11.x core/lib/Drupal/Core/Routing/RoutePreloader.php \Drupal\Core\Routing\RoutePreloader::isGetAndHtmlRoute()

Determines whether the given route is a GET and HTML route.

Parameters

\Symfony\Component\Routing\Route $route: The route to analyze.

Return value

bool TRUE if GET is a valid method and HTML is a valid format for this route.

1 call to RoutePreloader::isGetAndHtmlRoute()
RoutePreloader::onAlterRoutes in core/lib/Drupal/Core/Routing/RoutePreloader.php
Alters existing routes for a specific collection.

File

core/lib/Drupal/Core/Routing/RoutePreloader.php, line 121

Class

RoutePreloader
Defines a class that can pre-load non-admin routes.

Namespace

Drupal\Core\Routing

Code

protected static function isGetAndHtmlRoute(Route $route) {
    $methods = $route->getMethods() ?: [
        'GET',
    ];
    // If a route has no explicit format, then HTML is valid.
    // @see \Drupal\Core\Routing\RequestFormatRouteFilter::getAvailableFormats()
    $format = $route->hasRequirement('_format') ? explode('|', $route->getRequirement('_format')) : [
        'html',
    ];
    return in_array('GET', $methods, TRUE) && in_array('html', $format, TRUE);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.