* Copyright (C) 2011, StatusNet, Inc.
*
* URL mapper
- *
+ *
* PHP version 5
*
* This program is free software: you can redistribute it and/or modify
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
- * @category Cache
+ * @category URL
* @package StatusNet
* @author Evan Prodromou <evan@status.net>
* @copyright 2011 StatusNet, Inc.
*
* 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.
- *
+ * We used to use URLMapper, so there's a wrapper class at Router, q.v.
+ *
* NUM's vagaries are the main reason we have weirdnesses here.
*
* @category URL
protected $statics = array();
protected $variables = array();
protected $reverse = array();
+ protected $allpaths = array();
function connect($path, $args, $paramPatterns=array())
{
throw new Exception(sprintf("Can't connect %s; path has no action.", $path));
}
+ $allpaths[] = $path;
+
$action = $args[self::ACTION];
$paramNames = $this->getParamNames($path);
return $results;
}
}
-
+
throw new Exception(sprintf('No match for path "%s"', $path));
}
}
}
// success
- return $tryPath;
+ $path = $tryPath;
} else {
list($tryArgs, $format, $paramNames) = $candidate;
}
$path = vsprintf($format, $toFormat);
+ }
- if (!empty($qstring)) {
- $path .= '?' . http_build_query($qstring);
- }
-
- return $path;
+ if (!empty($qstring)) {
+ $formatted = http_build_query($qstring);
+ $path .= '?' . $formatted;
}
+
+ return $path;
}
+ // failure; some reporting twiddles
+
unset($args['action']);
if (empty($args)) {
array($pr, 'toPattern'),
$path);
- $regex = '#' . str_replace('#', '\#', $regex) . '#';
+ $regex = '#^' . str_replace('#', '\#', $regex) . '$#';
return $regex;
}
return $format;
}
+
+ public function getPaths()
+ {
+ return $this->allpaths;
+ }
}
class PatternReplacer