protected function UrlMatcher::matchCollection in Zircon Profile 8.0
Same name and namespace in other branches
- 8 vendor/symfony/routing/Matcher/UrlMatcher.php \Symfony\Component\Routing\Matcher\UrlMatcher::matchCollection()
Tries to match a URL with a set of routes.
Parameters
string $pathinfo The path info to be parsed:
RouteCollection $routes The set of routes:
Return value
array An array of parameters
Throws
ResourceNotFoundException If the resource could not be found
MethodNotAllowedException If the resource was found but the request method is not allowed
1 call to UrlMatcher::matchCollection()
- UrlMatcher::match in vendor/
symfony/ routing/ Matcher/ UrlMatcher.php - Tries to match a URL path with a set of routes.
1 method overrides UrlMatcher::matchCollection()
- TraceableUrlMatcher::matchCollection in vendor/
symfony/ routing/ Matcher/ TraceableUrlMatcher.php - Tries to match a URL with a set of routes.
File
- vendor/
symfony/ routing/ Matcher/ UrlMatcher.php, line 131
Class
- UrlMatcher
- UrlMatcher matches URL based on a set of routes.
Namespace
Symfony\Component\Routing\MatcherCode
protected function matchCollection($pathinfo, RouteCollection $routes) {
foreach ($routes as $name => $route) {
$compiledRoute = $route
->compile();
// check the static prefix of the URL first. Only use the more expensive preg_match when it matches
if ('' !== $compiledRoute
->getStaticPrefix() && 0 !== strpos($pathinfo, $compiledRoute
->getStaticPrefix())) {
continue;
}
if (!preg_match($compiledRoute
->getRegex(), $pathinfo, $matches)) {
continue;
}
$hostMatches = array();
if ($compiledRoute
->getHostRegex() && !preg_match($compiledRoute
->getHostRegex(), $this->context
->getHost(), $hostMatches)) {
continue;
}
// check HTTP method requirement
if ($requiredMethods = $route
->getMethods()) {
// HEAD and GET are equivalent as per RFC
if ('HEAD' === ($method = $this->context
->getMethod())) {
$method = 'GET';
}
if (!in_array($method, $requiredMethods)) {
$this->allow = array_merge($this->allow, $requiredMethods);
continue;
}
}
$status = $this
->handleRouteRequirements($pathinfo, $name, $route);
if (self::ROUTE_MATCH === $status[0]) {
return $status[1];
}
if (self::REQUIREMENT_MISMATCH === $status[0]) {
continue;
}
return $this
->getAttributes($route, $name, array_replace($matches, $hostMatches));
}
}