All pastes #611326 Raw Edit

Anonymous

public text v1 · immutable
·published 2007-07-09 21:34 UTC
rendered paste body
	final public function getRoutes()
	{
		$Controller = $this->Controller;
		$routes = $Controller->routes;
		$path = $this->path;
		
		if(isset($path) && isset($routes[$path[0]])) {
			$route = $routes[$path[0]];
			
			if(substr_count($route, '(') != substr_count($route, ')')) {
				throw new Exception();
			}
			
			$route = preg_split("~/~", $route, -1, PREG_SPLIT_NO_EMPTY);
			$route = array_combine($route, $path);
			
			$action = $route[0];
			
			array_shift($route);
			
			foreach($route as $key => $value) {
				preg_match("~\((?P<type>.*)\)(?P<key>.*)~", $key, $match);
				$this->variables[$match['key']] = typecast($value, $match['type']);
			}
		} else {
			$this->action = ($Controller->default_action) ? $Controller->default_action : 'index';
		}
	}