Skip to content

Commit

Permalink
Code formatting cleanup. Fixes #92.
Browse files Browse the repository at this point in the history
  • Loading branch information
predominant committed Dec 10, 2009
1 parent 931606f commit 8df7e34
Showing 1 changed file with 31 additions and 9 deletions.
40 changes: 31 additions & 9 deletions cake/libs/router.php
Expand Up @@ -1146,44 +1146,56 @@ function getArgs($args, $options = array()) {
* @see Router::connect
*/
class CakeRoute {

/**
* An array of named segments in a Route.
* `/:controller/:action/:id` has 3 named elements
*
* @var array
**/
* @access public
*/
var $keys = array();

/**
* An array of additional parameters for the Route.
*
* @var array
**/
* @access public
*/
var $options = array();
/**
* Default parameters for a Route
*
* @var array
* @access public
*/
var $defaults = array();

/**
* The routes template string.
*
* @var string
**/
* @access public
*/
var $template = null;

/**
* Is this route a greedy route? Greedy routes have a `/*` in their
* template
*
* @var string
**/
* @access protected
*/
var $_greedy = false;

/**
* The compiled route regular expresssion
*
* @var string
**/
* @access protected
*/
var $_compiledRoute = null;

/**
* HTTP header shortcut map. Used for evaluating header-based route expressions.
*
Expand All @@ -1195,27 +1207,32 @@ class CakeRoute {
'method' => 'request_method',
'server' => 'server_name'
);

/**
* Constructor for a Route
*
* @param string $template Template string with parameter placeholders
* @param array $defaults Array of defaults for the route.
* @param string $params Array of parameters and additional options for the Route
* @return void
* @access public
*/
function CakeRoute($template, $defaults = array(), $options = array()) {
$this->template = $template;
$this->defaults = (array)$defaults;
$this->options = (array)$options;
}

/**
* Check if a Route has been compiled into a regular expression.
*
* @return boolean
**/
* @access public
*/
function compiled() {
return !empty($this->_compiledRoute);
}

/**
* Compiles the routes regular expression. Modifies defaults property so all necessary keys are set
* and populates $this->names with the named routing elements.
Expand All @@ -1230,6 +1247,7 @@ function compile() {
$this->_writeRoute();
return $this->_compiledRoute;
}

/**
* Builds a route regular expression. Uses the template, defaults and options
* properties to compile a regular expression that can be used to match/parse request strings.
Expand Down Expand Up @@ -1284,6 +1302,7 @@ function _writeRoute() {
*
* @param string $url The url to attempt to parse.
* @return mixed Boolean false on failure, otherwise an array or parameters
* @access public
*/
function parse($url) {
if (!$this->compiled()) {
Expand Down Expand Up @@ -1338,6 +1357,7 @@ function parse($url) {
* @param array $url The array to apply persistent parameters to.
* @param array $params An array of persistent values to replace persistent ones.
* @return array An array with persistent parameters applied.
* @access public
*/
function persistParams($url, $params) {
foreach ($this->options['persist'] as $persistKey) {
Expand All @@ -1355,7 +1375,8 @@ function persistParams($url, $params) {
*
* @param array $url An array of parameters to check matching with.
* @return mixed Either a string url for the parameters if they match or false.
**/
* @access public
*/
function match($url) {
if (!$this->compiled()) {
$this->compile();
Expand Down Expand Up @@ -1428,13 +1449,14 @@ function match($url) {
}
return $this->_writeUrl(array_merge($url, compact('pass', 'named')));
}

/**
* Converts a matching route array into a url string.
*
* @params array $params The params to convert to a string url.
* @param array $params The params to convert to a string url.
* @return string Compiled route string.
* @access protected
**/
*/
function _writeUrl($params) {
if (isset($params['plugin'], $params['controller']) && $params['plugin'] === $params['controller']) {
unset($params['controller']);
Expand Down

0 comments on commit 8df7e34

Please sign in to comment.