Class Horde_Routes_Route

Description

The Route object holds a route recognition and generation routine.

See __construct() docs for usage.

Located in /Routes/lib/Horde/Routes/Route.php (line 21)


	
			
Variable Summary
 boolean $absolute
 array $conditions
 string $decodeErrors
 array $defaults
 string $encoding
 boolean $explicit
 callback $filter
 array $hardCoded
 array $maxKeys
 array $minKeys
 string $regexp
 array $reqs
 string $routePath
 string $static
 null|string $_collectionName
 null|string $_memberName
 string $_prior
 array $_reqRegs
 array $_routeList
 array $_splitChars
Method Summary
 Horde_Routes_Route __construct ( $routePath, [ $kargs = array()])
 array buildNextReg (array $path, array $clist)
 void generate (array $kargs, boolean|string 1)
 void makeRegexp (array $clist)
 null|array match (string $url, [array $kargs = array()])
 array _defaults ( $routeKeys, array $reservedKeys, array $kargs, array $routekeys)
 array _minKeys (array $routeList)
 array _pathKeys (string $routePath)
Variables
boolean $absolute (line 57)

Is this an absolute path? (Mapper will not prepend SCRIPT_NAME)

  • access: public
array $conditions (line 75)

Array of keyword args for special conditions (method, subDomain, function)

  • access: public
string $decodeErrors = 'replace' (line 39)

What to do on decoding errors? 'ignore' or 'replace'

  • access: public
array $defaults = array() (line 69)

Default keyword arguments for this route

  • access: public
string $encoding = 'utf-8' (line 33)

Encoding of this route (not yet supported)

  • access: public
boolean $explicit (line 63)

Does this route use explicit mode (no implicit defaults)?

  • access: public
callback $filter (line 51)

Filter function to operate on arguments before generation

  • access: public
array $hardCoded (line 93)

Default keywords that don't exist in the path; can't be changed by an incomng URL.

  • access: public
array $maxKeys (line 81)

Maximum keys that this route could utilize.

  • access: public
array $minKeys (line 87)

Minimum keys required to generate this route

  • access: public
string $regexp (line 105)

Regular expression for matching this route

  • access: public
array $reqs (line 99)

Requirements for this route

  • access: public
string $routePath (line 27)

The path for this route, such as ':controller/:action/:id'

  • access: public
string $static (line 45)

Is this a static route?

  • access: public
null|string $_collectionName (line 149)

Collection name if this is a RESTful route

  • see: resource()
  • access: protected
null|string $_memberName (line 142)

Member name if this is a RESTful route

  • see: resource()
  • access: protected
string $_parentResource (line 156)

Name of the parent resource, if this is a RESTful route & has a parent

  • see: resource
  • access: protected
string $_prior (line 129)

Last path part used by buildNextReg()

  • access: protected
array $_reqRegs (line 135)

Requirements formatted as regexps suitable for preg_match()

  • access: protected
array $_routeBackwards (line 117)

Reverse of $routeList

  • access: protected
array $_routeList (line 111)

Route path split by '/'

  • access: protected
array $_splitChars (line 123)

Characters that split the parts of a URL

  • access: protected
Methods
Constructor __construct (line 178)

Initialize a route, with a given routepath for matching/generation

The set of keyword args will be used as defaults.

Usage: $route = new Horde_Routes_Route(':controller/:action/:id');

$route = new Horde_Routes_Route('date/:year/:month/:day', array('controller'=>'blog', 'action'=>'view'));

$route = new Horde_Routes_Route('archives/:page', array('controller'=>'blog', 'action'=>'by_page', 'requirements' => array('page'=>'\d{1,2}'));

Note: Route is generally not called directly, a Mapper instance connect() method should be used to add routes.

  • access: public
Horde_Routes_Route __construct ( $routePath, [ $kargs = array()])
  • $routePath
  • $kargs
buildNextReg (line 445)

Recursively build a regexp given a path, and a controller list.

Returns the regular expression string, and two booleans that can be ignored as they're only used internally by buildnextreg.

  • return: [array, boolean, boolean]
  • access: public
array buildNextReg (array $path, array $clist)
  • array $path: The RouteList for the path
  • array $clist: List of all possible controllers
generate (line 692)

Generate a URL from ourself given a set of keyword arguments

  • access: public
void generate (array $kargs, boolean|string 1)
  • array $kargs: Keyword arguments
  • boolean|string 1: False if generation failed, URL otherwise
makeRegexp (line 419)

Create the regular expression for matching.

Note: This MUST be called before match can function properly.

clist should be a list of valid controller strings that can be matched, for this reason makeregexp should be called by the web framework after it knows all available controllers that can be utilized.

  • access: public
void makeRegexp (array $clist)
  • array $clist: List of all possible controllers
match (line 594)

Match a url to our regexp.

While the regexp might match, this operation isn't guaranteed as there's other factors that can cause a match to fail even though the regexp succeeds (Default that was relied on wasn't given, requirement regexp doesn't pass, etc.).

Therefore the calling function shouldn't assume this will return a valid dict, the other possible return is False if a match doesn't work out.

  • return: Array of match data if matched, Null otherwise
  • access: public
null|array match (string $url, [array $kargs = array()])
  • string $url: URL to match
  • array $kargs: Keyword arguments
_defaults (line 353)

Creates a default array of strings

Puts together the array of defaults, turns non-null values to strings, and add in our action/id default if they use and do not specify it

Precondition: $this->_defaultKeys is an array of the currently assumed default keys

  • return: [defaults, new default keys]
  • access: protected
array _defaults ( $routeKeys, array $reservedKeys, array $kargs, array $routekeys)
  • array $routekeys: All the keys found in the route path
  • array $reservedKeys: Array of keys not in the route path
  • array $kargs: Keyword args passed to the Route constructor
  • $routeKeys
_minKeys (line 319)

Utility function to walk the route backwards

Will determine the minimum keys we must have to generate a working route.

  • return: [minimum keys for route, route list reversed]
  • access: protected
array _minKeys (array $routeList)
  • array $routeList: Route path split by '/'
_pathKeys (line 261)

Utility method to walk the route, and pull out the valid dynamic/wildcard keys

  • return: Route list
  • access: protected
array _pathKeys (string $routePath)
  • string $routePath: Route path

Documentation generated on Sun, 30 Jan 2011 05:21:01 +0000 by phpDocumentor 1.4.3