/** * Matches a user submitted path with a previously defined route. * Assigns and returns an array of defaults on a successful match. * * @param EvHttp_Controller_Request_Http $request Request to get the path info from * @return array|false An array of assigned values or a false on a mismatch */ public function match($request, $partial = null) { $path = trim($request->getPathInfo(), '/'); $subPath = $path; $values = array(); foreach ($this->_routes as $key => $route) { if ($key > 0 && $matchedPath !== null) { $separator = substr($subPath, 0, strlen($this->_separators[$key])); if ($separator !== $this->_separators[$key]) { return false; } $subPath = substr($subPath, strlen($separator)); } // TODO: Should be an interface method. Hack for 1.0 BC if (!method_exists($route, 'getVersion') || $route->getVersion() == 1) { $match = $subPath; } else { $request->setPathInfo($subPath); $match = $request; } $res = $route->match($match, true); if ($res === false) { return false; } $matchedPath = $route->getMatchedPath(); if ($matchedPath !== null) { $subPath = substr($subPath, strlen($matchedPath)); $separator = substr($subPath, 0, strlen($this->_separators[$key])); } $values = $res + $values; } $request->setPathInfo($path); if ($subPath !== '' && $subPath !== false) { return false; } return $values; }