You are here

public function Router::matchRequest in Drupal 8

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/Routing/Router.php \Drupal\Core\Routing\Router::matchRequest()
1 call to Router::matchRequest()
Router::match in core/lib/Drupal/Core/Routing/Router.php
Tries to match a URL path with a set of routes.

File

core/lib/Drupal/Core/Routing/Router.php, line 122

Class

Router
Router implementation in Drupal.

Namespace

Drupal\Core\Routing

Code

public function matchRequest(Request $request) {
  $collection = $this
    ->getInitialRouteCollection($request);
  if ($collection
    ->count() === 0) {
    throw new ResourceNotFoundException(sprintf('No routes found for "%s".', $this->currentPath
      ->getPath()));
  }
  $collection = $this
    ->applyRouteFilters($collection, $request);
  $collection = $this
    ->applyFitOrder($collection);
  if ($ret = $this
    ->matchCollection(rawurldecode($this->currentPath
    ->getPath($request)), $collection)) {
    return $this
      ->applyRouteEnhancers($ret, $request);
  }
  throw 0 < count($this->allow) ? new MethodNotAllowedException(array_unique($this->allow)) : new ResourceNotFoundException(sprintf('No routes found for "%s".', $this->currentPath
    ->getPath()));
}