Class Service

Description

Class Service is a base class for HTTP application interfaces.

Services are the main HTTP interface to the resources of an application. A service should at least respond to one of the HTTP methods HEAD, GET, POST, PUT or DELETE which is called depending on the requested HTTP method by the client.

Services may register filters to specific Request methods. Use the add_filter() method in Service constructors to register a filter for a specific method.

Services also provide routing (delegation) to subroutines or other Services. Use the add_route() method in a constructor to add an entry to the routing table of your Service. Routing does NOT support service filters. Filters are processed only by the Dispatcher. Meaning that filters of the parent service are applied but filters of the plugin service are ignored.

  • see: Filter
  • see: Dispatcher
  • todo: outsource run() to dispatcher
  • todo: trigger other services through uri routes (internal use)
  • todo: default representation register

Located in /service.php (line 32)

PHOOL
   |
   --Service
Variable Summary
Method Summary
Service Service (Request &$request)
void add_filter (string $name, [string $method = 'global'])
void add_route (string $name, [string $func = false], [string $method = 'GET'], [string $obj = 'self'])
Forward|HTTPResponse delegate (string $name)
Forward|HTTPResponse|integer GET ()
array get_filters (string $method)
boolean has_route (string $name)
Forward|HTTPResponse plugin (string $name)
Forward|HTTPResponse|integer PUT ()
void set_forward (Forward &$f)
Variables
array $filters (line 62)

Service filters map

  • access: private
Forward $forward (line 38)

A Forward object to operate on

  • access: protected
string $method (line 50)

Requested HTTP Method

  • access: public
Request $request (line 44)

A Request object to operate on

  • access: protected
array $routes (line 56)

Service routing map

  • 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 Service (line 67)

Basic Service setup

Service Service (Request &$request)
add_filter (line 236)

Add a filter to a specific method of this Service

  • access: protected
void add_filter (string $name, [string $method = 'global'])
  • string $name: method name
  • string $method: filter name
add_route (line 258)

Register a subroutine or partner Service

  • access: protected
void add_route (string $name, [string $func = false], [string $method = 'GET'], [string $obj = 'self'])
  • string $name: service identifier in the URI
  • string $func: function name to delegate to
  • string $method: name of method to lookup for delegation
  • string $obj: real object name of the partner service
delegate (line 287)

Delegates action to a Subroutine or a Partner Service

Uses Reflection to invoke a subroutine with dynamic parameters.

  • return: result of the routing
  • access: private
Forward|HTTPResponse delegate (string $name)
  • string $name: route name
DELETE (line 143)

HTTP DELETE handler.

Put all Code to handle this Action on DELETE requests here.

  • return: result of a DELETE request
Forward|HTTPResponse|integer DELETE ()
GET (line 104)

HTTP GET handler.

Put all Code to handle this Action on GET requests here.

  • return: result of a GET request
Forward|HTTPResponse|integer GET ()
get_filters (line 213)

Return registered service filters for a specific method

array get_filters (string $method)
  • string $method: method name
has_route (line 273)

Check if a plugin is registered for the given method/action

  • access: private
boolean has_route (string $name)
  • string $name: service identifier to lookup for
HEAD (line 91)

HTTP HEAD handler.

Put all Code to return information about this Service here.

  • return: Service information
HTTPResponse HEAD ()
OPTIONS (line 161)

HTTP OPTIONS handler

Return a list of Methods implemented by this service.

  • return: implemented Methods
HTTPResponse OPTIONS ()
plugin (line 332)

Returns the result of a partner-service identified by $name

  • return: result of partner Service
  • access: private
Forward|HTTPResponse plugin (string $name)
  • string $name: name of service
POST (line 117)

HTTP POST handler.

Put all Code to handle this Action on POST requests here.

  • return: result of a POST request
Forward|HTTPResponse|integer POST ()
PUT (line 130)

HTTP PUT handler.

Put all Code to handle this Action on PUT requests here.

  • return: result of a PUT request
Forward|HTTPResponse|integer PUT ()
run (line 190)

Main Service Interface Method

Called by the Dispatcher to run a Service. This methods does a lookup for routing maps and/or calls the appropriate Handler.

  • return: Service result
set_forward (line 345)

Set a Forward object

void set_forward (Forward &$f)

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

Inherited Constants

Inherited from PHOOL

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

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