Welcome, Guest Log In

Class Krai_Router

Class Overview

The framework router

This class controls parsing request uris into the execution of module actions. It also generates uris from module and action data that will get back to that module and action when re-parsed. It also has functionality to load files in which live certain modules and actions.

Implements the Singleton pattern via Krai_Router::Instance().

Located in /Krai/Router.php [line 29]



		
		
		
		

Properties

Methods

[ Top ]
Property Summary
static Krai_Router   $_instance   Holds the singleton instance
array   $_reconstrmap   Holds the array of defined routes in entry order
boolean   $_routed   Flag for whether or not routing has already occurred.
array   $_routemap   Holds the array of defined routes sorted by complexity

[ Top ]
Method Summary
static Krai_Router   &Instance()   Singleton pattern constructor / retreiver
Krai_Router   __construct()   Constructor - private to implement singleton pattern
void   DoRoute()   Execute a route
void   ExecuteRoute()   Actually execute a route
string   UrlFor()   Generate the URL for a certain module and action

[ Top ]
Properties
static Krai_Router   $_instance = null [line 39]

Holds the singleton instance

This holds the single instance of the routing class.

API Tags:
Access:  private


[ Top ]
array   $_reconstrmap = array() [line 60]

Holds the array of defined routes in entry order

This is an array of Krai_Router_Route instances sorted in the order they were parsed out of the routes configuration file. It is used for reconstructing routes from module and action data.

API Tags:
Access:  private


[ Top ]
boolean   $_routed = false [line 70]

Flag for whether or not routing has already occurred.

This is a flag indicating whether or not Krai_Router::DoRoute() has been run yet.

API Tags:
Access:  private


[ Top ]
array   $_routemap = array() [line 49]

Holds the array of defined routes sorted by complexity

This is an array of arrays of Krai_Router_Route instances. It is in levels of complexity to make finding a matching route (perhaps) easier.

API Tags:
Access:  private


[ Top ]
Methods
static method Instance  [line 135]

  static Krai_Router &Instance( )

Singleton pattern constructor / retreiver

This function allows the retrieval of the singleton instance of the class.


API Tags:
Return:  The router instance
Access:  public


[ Top ]
Constructor __construct  [line 81]

  Krai_Router __construct( string $kvfurl  )

Constructor - private to implement singleton pattern

This function parses the routes configuration file and stores the route objects.

Parameters:
string   $kvfurl: 

API Tags:
Access:  private


[ Top ]
DoRoute  [line 156]

  void DoRoute( string $request  )

Execute a route

This function executes a route based on the parsing of the request parameter. It can only be called once, and after that will throw a Krai_Router_Exception.

Parameters:
string   $request:  The requested uri

API Tags:
Access:  public

Information Tags:
Throws:  Krai_Router_Exception

[ Top ]
ExecuteRoute  [line 219]

  void ExecuteRoute( string $_module, string $_action, [ $_params = array()]  )

Actually execute a route

This function implements the actual execution of a route by instantiating the required module and calling the module's Krai_Module::DoAction() method.

Parameters:
string   $_module:  The name of the module to instantiate
string   $_action:  The name of the action to execute
array   $_params:  The parameters of the request

API Tags:
Access:  public

Information Tags:
Throws:  Krai_Router_Exception

[ Top ]
UrlFor  [line 249]

  string UrlFor( string $_module, string $_action, [ $_params = array()], [boolean $_forlink = true]  )

Generate the URL for a certain module and action

This function generates a uri representing a certain combination of module, action, and parameters which, when parsed, would execute the same.

Parameters:
string   $_module:  The name of the module
string   $_action:  The name of the action
array   $_params:  An array of parameters
boolean   $_forlink:  Whether or not to encode the uri returned for use in a link

API Tags:
Return:  The uri (including BASEURI).
Access:  public


[ Top ]

Documentation generated on Fri, 25 Jul 2008 15:19:53 -0400 by phpDocumentor 1.4.2
Krai Framework site admin credits sitemap valid xhtml?