private static function format() {

		$routes = static :: getRoutes();

		foreach($routes as $identifier => $route) {

			$url = preg_quote($route -> getUrl(), '/'); 

			//Prepend prefix for url
			if($prefix = $route -> getPrefix()) {
				$url = $prefix['url'] . $url;
			}

			if(preg_match_all('#(\\\/)*\\\{([a-zA-Z0-9_.]+)(\\\\\?)?\\\}#i', $url, $matches)) {
				
				foreach($matches[0] as $index => $match) {

					$match 		= $matches[0][$index];
					$slash 		= $matches[1][$index];
					$type 		= $matches[2][$index];
					$optional 	= $matches[3][$index];
					$where 		= $route -> getWhere();
					$variable 	= '';
					$typefound 	= false;

					if('' !== $slash) {
						$variable .= '\/';
					}

					if(true === is_array($where)) {
						
						foreach($where as $key => $regex) {
							
							if($key === $type) {
								
								$variable .= $regex;
								$typefound = true;
								break;
							}
						}
					}

					if(false === $typefound) {

						if(isset(static :: $types[$type])) {
							$variable .= static :: $types[$type];
						}
						else {
							$variable .= static :: $types['string'];	
						}
					}

					if('' !== $optional) {
						$variable = '('. $variable .')?';
					}
					else {
						$variable = '('. $variable .')';
					}
					
					$url = preg_replace('#' . preg_quote($match, '/') . '#', $variable, $url, 1);
				}
			}

			$route -> setMatch($url);
		}
	}
private static function format() {

		$routes = static :: getRoutes();

		foreach($routes as $identifier => $route) {

			$url = preg_quote($route -> getUrl(), '/'); 

			//Prepend prefix for url
			if($prefix = $route -> getPrefix()) {
				$url = $prefix['url'] . $url;
			}

			if(preg_match_all('#(\\\/)*\\\{([a-zA-Z0-9_.]+)(\\\\\?)?\\\}#i', $url, $matches)) {
				
				foreach($matches[0] as $index => $match) {

					$match 		= $matches[0][$index];
					$slash 		= $matches[1][$index];
					$type 		= $matches[2][$index];
					$optional 	= $matches[3][$index];
					$where 		= $route -> getWhere();
					$variable 	= '';
					$typefound 	= false;

					if('' !== $slash) {
						$variable .= '\/';
					}

					if(true === is_array($where)) {
						
						foreach($where as $key => $regex) {
							
							if($key === $type) {
								
								$variable .= $regex;
								$typefound = true;
								break;
							}
						}
					}

					if(false === $typefound) {

						if(isset(static :: $types[$type])) {
							$variable .= static :: $types[$type];
						}
						else {
							$variable .= static :: $types['string'];	
						}
					}

					if('' !== $optional) {
						$variable = '('. $variable .')?';
					}
					else {
						$variable = '('. $variable .')';
					}
					
					$url = preg_replace('#' . preg_quote($match, '/') . '#', $variable, $url, 1);
				}
			}

			$route -> setMatch($url);
		}
	}
private static function format ( ) { $ routes = static :: getRoutes ( ) ; foreach ( $ routes as $ identifier => $ route ) { $ url = preg_quote ( $ route -> getUrl ( ) , '/' ) ; //Prepend prefix for url
 if ( $ prefix = $ route -> getPrefix ( ) ) { $ url = $ prefix [ 'url' ] . $ url ; } if ( preg_match_all ( '#(\\\/)*\\\{([a-zA-Z0-9_.]+)(\\\\\?)?\\\}#i' , $ url , $ matches ) ) { foreach ( $ matches [ 0 ] as $ index => $ match ) { $ match = $ matches [ 0 ] [ $ index ] ; $ slash = $ matches [ 1 ] [ $ index ] ; $ type = $ matches [ 2 ] [ $ index ] ; $ optional = $ matches [ 3 ] [ $ index ] ; $ where = $ route -> getWhere ( ) ; $ variable = '' ; $ typefound = false ; if ( '' !== $ slash ) { $ variable .= '\/' ; } if ( true === is_array ( $ where ) ) { foreach ( $ where as $ key => $ regex ) { if ( $ key === $ type ) { $ variable .= $ regex ; $ typefound = true ; break ; } } } if ( false === $ typefound ) { if ( isset ( static :: $ types [ $ type ] ) ) { $ variable .= static :: $ types [ $ type ] ; } else { $ variable .= static :: $ types [ 'string' ] ; } } if ( '' !== $ optional ) { $ variable = '(' . $ variable . ')?' ; } else { $ variable = '(' . $ variable . ')' ; } $ url = preg_replace ( '#' . preg_quote ( $ match , '/' ) . '#' , $ variable , $ url , 1 ) ; } } $ route -> setMatch ( $ url ) ; } }
Formats all the routes urls to a regex pattern that sFire understands to match the current url to the route url
Formats all the routes urls to a regex pattern that sFire understands to match the current url to the route url