You are here

public function DynamicRouter::matchRequest in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony-cmf/routing/DynamicRouter.php \Symfony\Cmf\Component\Routing\DynamicRouter::matchRequest()

Tries to match a request with a set of routes and returns the array of information for that route.

If the matcher can not find information, it must throw one of the exceptions documented below.

Parameters

Request $request The request to match:

Return value

array An array of parameters

Throws

ResourceNotFoundException If no matching resource could be found

MethodNotAllowedException If a matching resource was found but the request method is not allowed

Overrides RequestMatcherInterface::matchRequest

File

vendor/symfony-cmf/routing/DynamicRouter.php, line 241

Class

DynamicRouter
A flexible router accepting matcher and generator through injection and using the RouteEnhancer concept to generate additional data on the routes.

Namespace

Symfony\Cmf\Component\Routing

Code

public function matchRequest(Request $request) {
  if ($this->eventDispatcher) {
    $event = new RouterMatchEvent($request);
    $this->eventDispatcher
      ->dispatch(Events::PRE_DYNAMIC_MATCH_REQUEST, $event);
  }
  if (!empty($this->uriFilterRegexp) && !preg_match($this->uriFilterRegexp, $request
    ->getPathInfo())) {
    throw new ResourceNotFoundException("{$request->getPathInfo()} does not match the '{$this->uriFilterRegexp}' pattern");
  }
  $matcher = $this
    ->getMatcher();
  if ($matcher instanceof UrlMatcherInterface) {
    $defaults = $matcher
      ->match($request
      ->getPathInfo());
  }
  else {
    $defaults = $matcher
      ->matchRequest($request);
  }
  return $this
    ->applyRouteEnhancers($defaults, $request);
}