Class Dispatcher

Description

The Dispatcher class is responsible for mapping urls/routes to Controller methods.

Each route that has the same number of directory components as the current requested url is tried, and the first method that returns a response with a non false/non null value will be returned via the Dispatcher::dispatch() method.

For example:

A route string can be a literal uri such as '/pages/about' or can contain wildcards (:any or :num) and/or regex like '/blog/:num' or '/page/:any'.

  1.       '/' => 'page/index',
  2.       '/about' => 'page/about,
  3.       '/blog/:num' => 'blog/post/$1',
  4.       '/blog/:num/comment/:num/delete' => 'blog/deleteComment/$1/$2'
  5.  ));

Visiting /about/ would call PageController::about(), visiting /blog/5 would call BlogController::post(5) visiting /blog/5/comment/42/delete would call BlogController::deleteComment(5,42)

The dispatcher is used by calling Dispatcher::addRoute() to setup the route(s), and Dispatcher::dispatch() to handle the current request and get a response.

Located in /wolf/Framework.php (line 99)


	
			
Method Summary
static void addRoute (string $route, [string $destination = null])
static string dispatch ([string $requested_url = null], [string $default = null])
static void executeAction (string $controller, string $action, array $params)
static string getAction ()
static string getController ()
static string getCurrentUrl ()
static array getParams ()
static getStatus ([ $key = null])
static boolean hasRoute (string $requested_url)
static array splitUrl (string $url)
Methods
static method addRoute (line 111)

Adds a route.

  • access: public
static void addRoute (string $route, [string $destination = null])
  • string $route: A route string.
  • string $destination: URI that the request should be sent to.
static method dispatch (line 168)

Handles the request for a URL and provides a response.

  • return: A response.
  • access: public
static string dispatch ([string $requested_url = null], [string $default = null])
  • string $requested_url: The URL that was requested.
  • string $default: Default URL to access if now URL was requested.
static method executeAction (line 299)

Executes a specified action for a specified controller class.

  • access: public
static void executeAction (string $controller, string $action, array $params)
  • string $controller
  • string $action
  • array $params
static method getAction (line 267)

Returns the action that was requested from a controller.

  • return: Reference to a controller's action.
  • access: public
static string getAction ()
static method getController (line 248)

Returns a reference to a controller class.

  • return: Reference to controller.
  • access: public
static string getController ()
static method getCurrentUrl (line 239)

Returns the currently requested URL.

  • return: The currently requested URL.
  • access: public
static string getCurrentUrl ()
static method getParams (line 276)

Returns an array of parameters that should be passed to an action.

  • return: The action's parameters.
  • access: public
static array getParams ()
static method getStatus (line 288)

???

  • todo: Finish docblock
  • access: public
static getStatus ([ $key = null])
  • $key
static method hasRoute (line 125)

Checks if a route exists for a specified URI.

  • return: Returns true when a route was found, otherwise false.
  • access: public
static boolean hasRoute (string $requested_url)
  • string $requested_url
static method splitUrl (line 157)

Splits a URL into an array of its components.

  • return: An array of URL components.
  • access: public
static array splitUrl (string $url)
  • string $url: A URL.

Documentation generated on Thu, 12 May 2011 23:23:55 +0200 by phpDocumentor 1.4.3