/** * Generate a short url for given arguments. * * @param Zigra_Request $request Request. * @param bool $resetProperties If reset or not all singleton proprieties. * * @return bool true when route is found or false if not found. */ private static function process(Zigra_Request $request, $resetProperties = false) { $routes = self::$_compiledRouteCollection->routes; foreach ($routes as $route) { $request_parts = parse_url($request->getRequest()); if (!isset($request_parts['path'])) { $request_parts['path'] = null; } preg_match($route[0]['regex'], $request_parts['path'], $matches); if (count($matches)) { //remove numeric index from array $matches_filter = array_filter(array_keys($matches), 'is_string'); $matches = array_intersect_key($matches, array_flip($matches_filter)); $args = array(); foreach ($route[0]['variables'] as $variable) { $args[$variable] = array_shift($matches); } self::$_controller = !isset(self::$_controller) || $resetProperties ? $route[0]['defaults']['controller'] : self::$_controller; self::$_action = !isset(self::$_action) || $resetProperties ? $route[0]['defaults']['action'] : self::$_action; self::$_args = !isset(self::$_args) || $resetProperties ? $args : self::$_args; self::$_defaults = !isset(self::$_defaults) || $resetProperties ? $route[0]['defaults'] : self::$_defaults; if (isset($request_parts['query'])) { parse_str($request_parts['query'], $query_args); self::$_args = array_merge(self::$_args, $query_args); } return true; } } self::$_controller = !isset(self::$_controller) || $resetProperties ? $request->getController() : self::$_controller; self::$_action = !isset(self::$_action) || $resetProperties ? $request->getAction() : self::$_action; self::$_args = !isset(self::$_args) || $resetProperties ? $request->getArgs() : self::$_args; self::$_defaults = array(); return false; }