X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=lib%2Furlmapper.php;h=931b5c3c2a1cf554a5f35ac7229d7e2fa59a0c82;hb=c285f80b1830cffd20a28c693d74c59f8c3c39f6;hp=fcaa66a55315b46fd5606ae74b0f107ee77c0794;hpb=7c03a509474235d7f81d9d9e14a683f045882ce2;p=quix0rs-gnu-social.git diff --git a/lib/urlmapper.php b/lib/urlmapper.php index fcaa66a553..931b5c3c2a 100644 --- a/lib/urlmapper.php +++ b/lib/urlmapper.php @@ -4,7 +4,7 @@ * Copyright (C) 2011, StatusNet, Inc. * * URL mapper - * + * * PHP version 5 * * This program is free software: you can redistribute it and/or modify @@ -40,7 +40,7 @@ if (!defined('STATUSNET')) { * Converts a path into a set of parameters, and vice versa * * We used to use Net_URL_Mapper, so there's a wrapper class at Router, q.v. - * + * * NUM's vagaries are the main reason we have weirdnesses here. * * @category URL @@ -58,6 +58,7 @@ class URLMapper protected $statics = array(); protected $variables = array(); protected $reverse = array(); + protected $allpaths = array(); function connect($path, $args, $paramPatterns=array()) { @@ -65,6 +66,8 @@ class URLMapper throw new Exception(sprintf("Can't connect %s; path has no action.", $path)); } + $this->allpaths[] = $path; + $action = $args[self::ACTION]; $paramNames = $this->getParamNames($path); @@ -89,7 +92,7 @@ class URLMapper } } - $regex = $this->makeRegex($path, $paramPatterns); + $regex = self::makeRegex($path, $paramPatterns); $this->variables[] = array($args, $regex, $paramNames); @@ -119,8 +122,8 @@ class URLMapper return $results; } } - - throw new Exception(sprintf('No match for path "%s"', $path)); + + throw new NoRouteMapException($path); } function generate($args, $qstring, $fragment) @@ -173,7 +176,7 @@ class URLMapper $path = vsprintf($format, $toFormat); } - if (!empty($qstring)) { + if (!empty($qstring)) { $formatted = http_build_query($qstring); $path .= '?' . $formatted; } @@ -204,7 +207,7 @@ class URLMapper return $match['name']; } - protected function makeRegex($path, $paramPatterns) + static function makeRegex($path, $paramPatterns) { $pr = new PatternReplacer($paramPatterns); @@ -223,6 +226,11 @@ class URLMapper return $format; } + + public function getPaths() + { + return $this->allpaths; + } } class PatternReplacer