Class Dispatcher

Description

Dispatcher to route URI request to appropriate controller / method, and loads view files based on instructions from the controller, passing data setup by the controller from the controller to the view file.

Located in /class.dispatcher.php (line 25)


                
			
Method Summary
static boolean IsAjaxRequest ()
void AddRoute (string $sPattern, string $sReplacement)
void Connect (string $sRequest)
void Invoke404Error ()
void InvokeAction (Request &$oRequest, Request $oRequest)
void LoadView (Request &$oRequest, Request $oRequest)
void RequireViewFiles (bool $bRequireViewFiles)
void Set404Handler (callback $xCallback)
void Set404View (string $sView)
void SetFooterView ([string $sView = ""])
void SetHeaderView ([string $sView = ""])
Methods
static method IsAjaxRequest (line 244)

Determines whether or not the current HTTP request came via AJAX.

  • return: True of the request is via AJAX, false otherwise
  • access: public
static boolean IsAjaxRequest ()
AddRoute (line 141)

Sets up a custom route to match a URI against when dispatching the URI. A custom route is simply run by running a preg_match against the URI, and rewriting it to the replacement on a valid match using preg_replace.

  • access: public
void AddRoute (string $sPattern, string $sReplacement)
  • string $sPattern: The pattern to match against
  • string $sReplacement: The string to rewrite to
Connect (line 168)

Routes the specified request to an associated controller and action (class and method).

Loads any specified view file stored in the controller and passes along any data stored in the controller.

This method checks for custom routes first (see AddRoute()), before checking for standard routes. A standard route is a UI formed as follows /[controllername]/[methodname] where [controllername] is the name of the controller, without the word "controller"

A standard controller is named like: ExampleController. To invoke the index method of this controller, one would navigate to /example/index.

The data loaded via the controller's SetData() method is exploded and available for the view file.

  • access: public
void Connect (string $sRequest)
  • string $sRequest: The current request URI
Invoke404Error (line 335)

Internally handles a 404 error, loads the 404 error view file or calls the 404 callback handler if one is defined.

  • access: protected
void Invoke404Error ()
InvokeAction (line 257)

Called from Connect(), responsible for calling the method of the controller routed from the URI

  • access: protected
void InvokeAction (Request &$oRequest, Request $oRequest)
  • Request $oRequest: The Request object for the current HTTP request
  • Request &$oRequest
LoadView (line 289)

Called from Connect(), responsible for loading any view file

  • access: protected
void LoadView (Request &$oRequest, Request $oRequest)
  • Request $oRequest: The Request object for the current HTTP request
  • Request &$oRequest
RequireViewFiles (line 64)

Toggles whether or not the controller should load view files (header, the view setup by the controller, and the footer view file.

  • access: public
void RequireViewFiles (bool $bRequireViewFiles)
  • bool $bRequireViewFiles: True if views should be required, false otherwise
Set404Handler (line 126)

Allows the specification of a callback method to invoke upon a 404 error, instead of requiring the 404 view file. If this callback is not callable, nothing will happen on a 404 error.

  • access: public
void Set404Handler (callback $xCallback)
  • callback $xCallback: The callback to invoke upon a 404 error
Set404View (line 78)

Sets the name of the view file to load in the event of a 404 error. By default, if no view file is specified, the file the dispatcher will attempt to load is "404.php". The include path will be used to search for this file.

  • access: public
void Set404View (string $sView)
  • string $sView: The file name of the view file to load in the event of a 404 error
SetFooterView (line 112)

Sets the name of the footer file to load after loading the controller-specified view file. The default file loaded for the footer is "footer.php." The purpose of this method is to override the default.

Passing null or an empty string, or supplying no argument at all, to this method will cause the dispatcher to not load any footer view file at all.

  • access: public
void SetFooterView ([string $sView = ""])
  • string $sView: Optional; The name of the file to load as the footer. Default: none
SetHeaderView (line 95)

Sets the name of the header file to load before loading the controller-specified view file. The default file loaded for the header is "header.php." The purpose of this method is to override the default.

Passing null or an empty string, or supplying no argument at all, to this method will cause the dispatcher to not load any header view file at all.

  • access: public
void SetHeaderView ([string $sView = ""])
  • string $sView: Optional; The name of the file to load as the header. Default: none

Documentation generated on Thu, 25 Feb 2010 15:59:40 -0500 by phpDocumentor 1.4.3