Tries to match a URL path with a set of routes.
If the matcher can not find information, it must throw one of the exceptions documented below.
@api
string $pathinfo The path info to be parsed (raw format, i.e. not urldecoded):
array An array of parameters
ResourceNotFoundException If the resource could not be found
MethodNotAllowedException If the resource was found but the request method is not allowed
Overrides UrlMatcher::match
public function match($pathinfo) {
$allow = array();
$pathinfo = rawurldecode($pathinfo);
if (0 === strpos($pathinfo, '/rootprefix')) {
// static
if ($pathinfo === '/rootprefix/test') {
return array(
'_route' => 'static',
);
}
// dynamic
if (preg_match('#^/rootprefix/(?P<var>[^/]++)$#s', $pathinfo, $matches)) {
return $this
->mergeDefaults(array_replace($matches, array(
'_route' => 'dynamic',
)), array());
}
}
throw 0 < count($allow) ? new MethodNotAllowedException(array_unique($allow)) : new ResourceNotFoundException();
}