The mapper class handles URL generation and recognition for web applications
The mapper class is built by handling associated arrays of information and passing associated arrays back to the application for it to handle and dispatch the appropriate scripts.
Located in /Routes/lib/Horde/Routes/Mapper.php (line 24)
Call controllerScan callback before every route match?
Append trailing slash ('/') to generated routes?
Callback function used to get array of controller names
Collect debug information during route match?
What to do on decoding errors? 'ignore' or 'replace'
Path to controller directory passed to controllerScan function
Partial regexp used to match domain part of the end of URLs to match
Encoding of routes URLs (not yet supported)
Filtered request environment with keys like SCRIPT_NAME
Disable route memory and implicit defaults?
Array of connected routes
Array of all connected routes, indexed by the serialized array of all keys that each route could utilize.
Array of all connected routes, indexed by the serialized array of the minimum keys that each route needs.
Prefix to strip during matching and to append during generation
Array of connected named routes, indexed by name
Use sub-domain support?
Array of sub-domains to ignore if using sub-domain support
Cache of URLs used in generate()
Utility functions like urlFor() and redirectTo() for this Mapper
Have generation hashes been created for all connected routes?
Have regular expressions been created for all connected routes?
Generation hashes created for all connected routes
Temporary variable used to pass array of keys into _keysort() callback
Regular expression generated to match after the prefix
Constructor.
Keyword arguments ($kargs): ``controllerScan`` (callback) Function to return an array of valid controllers
``redirect`` (callback) Function to perform a redirect for Horde_Routes_Utils->redirectTo()
``directory`` (string) Path to the directory that will be passed to the controllerScan callback
``alwaysScan`` (boolean) Should the controllerScan callback be called before every URL match?
``explicit`` (boolean) Should routes be connected with the implicit defaults of array('controller'=>'content', 'action'=>'index', 'id'=>null)? When set to True, these will not be added to route connections.
Create and connect a new Route to the Mapper.
Usage: $m = new Horde_Routes_Mapper(); $m->connect(':controller/:action/:id'); $m->connect('date/:year/:month/:day', array('controller' => "blog", 'action' => 'view'); $m->connect('archives/:page', array('controller' => 'blog', 'action' => 'by_page', ' requirements' => array('page' => '\d{1,2}'))); $m->connect('category_list', 'archives/category/:section', array('controller' => 'blog', 'action' => 'category', 'section' => 'home', 'type' => 'list')); $m->connect('home', '', array('controller' => 'blog', 'action' => 'view', 'section' => 'home'));
Creates the regexes for all connected routes
Generates the URL from a given set of keywords Returns the URL text, or null if no URL could be generated.
Usage: $m->generate(array('controller' => 'content', 'action' => 'view', 'id' => 10));
Match a URL against one of the routes contained.
It will return null if no valid match is found.
Usage: $resultdict = $m->match('/joe/sixpack');
Generate routes for a controller resource
The $memberName name should be the appropriate singular version of the resource given your locale and used with members of the collection.
The $collectionName name will be used to refer to the resource collection methods and should be a plural version of the $memberName argument. By default, the $memberName name will also be assumed to map to a controller you create.
The concept of a web resource maps somewhat directly to 'CRUD' operations. The overlying things to keep in mind is that mapping a resource is about handling creating, viewing, and editing that resource.
All keyword arguments ($kargs) are optional.
``controller`` If specified in the keyword args, the controller will be the actual controller used, but the rest of the naming conventions used for the route names and URL paths are unchanged.
``collection`` Additional action mappings used to manipulate/view the entire set of resources provided by the controller.
Example::
$map->resource('message', 'messages', array('collection' => array('rss' => 'GET)));
Example::
$map->resource('message', 'messages', array('member' => array('mark' => 'POST')));
Example::
$map->resource('message', 'messages', array('new' => array('preview' => 'POST')));
``namePrefix`` Perpends the route names that are generated with the namePrefix given. Combined with the pathPrefix option, it's easy to generate route names and paths that represent resources that are in relations.
Example::
map.resource('message', 'messages', array('controller' => 'categories', 'pathPrefix' => '/category/:category_id', 'namePrefix' => 'category_')));
If ``parentResource`` is supplied and ``pathPrefix`` isn't, ``pathPrefix`` will be generated from ``parentResource`` as "<parent collection name>/:<parent member name>_id".
If ``parentResource`` is supplied and ``namePrefix`` isn't, ``namePrefix`` will be generated from ``parentResource`` as "<parent member name>_".
Example::
$m = new Horde_Routes_Mapper(); $utils = $m->utils;
$m->resource('location', 'locations', array('parentResource' => array('memberName' => 'region', 'collectionName' => 'regions'))));
$m = new Horde_Routes_Mapper(); $utils = new Horde_Routes_Utils();
$m->resource('location', 'locations', array('parentResource' => array('memberName' => 'region', 'collectionName' => 'regions'), 'pathPrefix' => 'areas/:area_id')));
$m = new Horde_Routes_Mapper $m->resource('location', 'locations', array('parentResource' => array('memberName' => 'region', 'collectionName' => 'regions'), 'namePrefix' => '')));
Match a URL against one of the routes contained.
It will return null if no valid match is found, otherwise a result dict (array) and a route object is returned.
Usage: list($resultdict, $resultobj) = $m->match('/joe/sixpack');
Create a union of two arrays.
Equivalent of Python's cmp() function.
Create the generation hashes (arrays) for route lookups
Compare two Horde_Route_Routes objects by their keys against the instance variable $keysortTmp. Used by _keysort().
Sort an array of Horde_Routes_Routes to using _keycmp() for the comparision to order them ideally for matching.
An unfortunate property of PHP's usort() is that if two members compare equal, their order in the sorted array is undefined (see PHP manual). This is unsuitable for us because the order that the routes were connected to the mapper is significant.
Uses this method uses merge sort algorithm based on the comments in http://www.php.net/usort
Internal Route matcher
Matches a URL against a route, and returns a tuple (array) of the match dict (array) and the route object if a match is successful, otherwise it returns null.
Returns a new dict to be used for all route creation as the route options.
Trims slashes from the beginning or end of a part/URL.
Swap the keys and values in the dict, and uppercase the values from the dict during the swap.
Documentation generated on Sun, 30 Jan 2011 05:19:31 +0000 by phpDocumentor 1.4.3