public function ChainMatcher::matchRequest

Matches a request against all queued matchers.

Parameters

Request $request The request to match:

Return value

array An array of parameters

Throws

\Symfony\Component\Routing\Exception\ResourceNotFoundException If no matching resource could be found

\Symfony\Component\Routing\Exception\MethodNotAllowedException If a matching resource was found but the request method is not allowed

Overrides RequestMatcherInterface::matchRequest

File

drupal/core/lib/Drupal/Core/Routing/ChainMatcher.php, line 98
Definition of Drupal\Core\Routing\ChainMatcher.

Class

ChainMatcher
Aggregates multiple matchers together in series.

Namespace

Drupal\Core\Routing

Code

public function matchRequest(Request $request) {
  $methodNotAllowed = null;
  foreach ($this
    ->all() as $matcher) {
    try {
      return $matcher
        ->matchRequest($request);
    } catch (ResourceNotFoundException $e) {

      // Needs special care
    } catch (MethodNotAllowedException $e) {
      $methodNotAllowed = $e;
    }
  }
  throw $methodNotAllowed ?: new ResourceNotFoundException("None of the matchers in the chain matched this request.");
}