Class Dispatcher

Description

The Dispatcher is the top level controller for the HTTP Interface of your Application

The Dispatcher receives a HTTPRequest object, creates the requested Service object as well as the filters attached to the Service and processes them all together. It keeps track of the application status using a Forward object and finally creates and renders a View to display. The Dispatcher is the only interface to services for an application.

Dispatcher provides a few setters to tweak application control:

  • set_default: set a default service, view, template or renderer as fallback
  • set_debug: set a debug level for the application ErrorHandler
  • set_response: override a default response for a given http status
  • add_filter: add a global filter to the internal filters list

Located in /dispatcher.php (line 31)

PHOOL
   |
   --Dispatcher
Class Constant Summary
 F_INTER = 2
 F_POST = 3
 F_PRE = 1
 OUT = 2
 RET = 1
Variable Summary
Method Summary
Dispatcher Dispatcher (Request &$r, [ $gw = false])
void add_filter (string $name)
void &get_filter (string $fname, int $type)
object HTTPResponse &get_response (integer $status)
boolean process_filters ([string $type = self::F_PRE])
HTTPResponse release ([ $retype = self::RET])
void set_default (string $type, string $name)
void set_prefix (string $pref)
void set_response (integer $status, string $name)
Variables
array $defaults (line 102)

Default components to load if non given

  • access: private
array $filters (line 68)

Filters to execute

  • access: public
Forward $forward (line 50)

The application forward object

  • access: public
Gateway $gateway (line 43)

A gateway for service protection

  • access: public
string $prefix (line 108)

Optional Servicename Prefix

  • access: private
Request $request (line 37)

Request object to handle

  • access: public
HTTPResponse $response (line 56)

A response object

  • access: public
array $responses = array(

// 2xx success responses
200 => 'View',
201 => 'Created',
204 => 'NoContent',

// 4xx failure responses
400 => 'BadRequest',
401 => 'Authenticate',
403 => 'Forbidden',
404 => 'NotFound',
405 => 'NotAllowed',
406 => 'NotAcceptable',
412 => 'ConditionFailure',

// 5xx failure responses
500 => 'ServerError',
501 => 'NotImplemented',
502 => 'BadGateway',
503 => 'Unavailable'

)
(line 74)

Response Names to load from HTTP Code

  • access: public
string $service (line 62)

Name of service to dispatch

  • access: public

Inherited Variables

Inherited from PHOOL

PHOOL::$debug
PHOOL::$errorlabels
PHOOL::$errorlevels
PHOOL::$errors
PHOOL::$exists
PHOOL::$logdir
PHOOL::$loglevel
PHOOL::$objname
Methods
Constructor Dispatcher (line 126)

Construct a Dispatcher object

Dispatcher Dispatcher (Request &$r, [ $gw = false])
add_filter (line 344)

Apply a filter to the main dispatcher.

void add_filter (string $name)
  • string $name: name of filter
get_filter (line 416)

Create, validate and return a filter

  • access: private
void &get_filter (string $fname, int $type)
  • string $fname: name of filter in registry
  • int $type: type of filter to return
get_response (line 446)

Create a HTTPResponse from a given Status Code

object HTTPResponse &get_response (integer $status)
  • integer $status: HTTP Status
process_filters (line 369)

Execute Filter, pass type of filtering to this method.

  • return: filter success
  • todo: register servicename into filter
  • access: private
boolean process_filters ([string $type = self::F_PRE])
  • string $type: filtertype
release (line 155)

Unleash application

HTTPResponse release ([ $retype = self::RET])
  • $retype
set_default (line 314)

Set a default service, view or renderer

void set_default (string $type, string $name)
  • string $type: type of default to set
  • string $name: name of default module
set_prefix (line 355)

Set a service name prefix

void set_prefix (string $pref)
  • string $pref: prefix to set
set_response (line 332)

Override a response type with a custom View

void set_response (integer $status, string $name)
  • integer $status: status code of response to set
  • string $name: name of the response Class

Inherited Methods

Inherited From PHOOL

PHOOL::PHOOL()
PHOOL::debug()
PHOOL::error()
PHOOL::get_errors()
PHOOL::handle_error()
PHOOL::has_error()
PHOOL::log_error()
PHOOL::set_debug()
PHOOL::set_logdir()
PHOOL::set_loglevel()
Class Constants
F_INTER = 2 (line 120)
F_POST = 3 (line 121)
F_PRE = 1 (line 119)

Filter type constants

OUT = 2 (line 114)
RET = 1 (line 113)

Release result types: return or output

Inherited Constants

Inherited from PHOOL

PHOOL::ERROR
PHOOL::UNKNOWN
PHOOL::USER
PHOOL::WARNING

Documentation generated on Tue, 12 May 2009 23:09:38 +0200 by phpDocumentor 1.4.1