protected function doMatch($pathinfo, Request $request = null)
{
$notAllowed = null;
foreach ($this->sort() as $matcher) {
$matcher->setContext($this->context);
try {
if ($request && $matcher instanceof RequestMatcherInterface) {
return $matcher->matchRequest($request);
}
return $matcher->match($pathinfo);
} catch (ResourceNotFoundException $e) {
// Special case
} catch (MethodNotAllowedException $e) {
$notAllowed = $e;
}
}
if ($notAllowed) {
throw $notAllowed;
}
$info = $request ? 'this request\\n' . $request : 'url "' . $pathinfo . '"';
throw new ResourceNotFoundException('None of the routers in the chain matched ' . $info);
}