Class PHRUTS_ActionService

Description

PHRUTS_ActionService represents the "controller" in the Model-View-Controller (MVC) design pattern for web applications that is commonly known as "Model 2".

Generally, a "Model 2" application is architected as follows:

  • The user interface will generally be created with PHP pages, which will not themselves contain any business logic. These pages represent the "view" component of an MVC architecture.
  • Forms and hyperlinks in the user interface that require business logic to be executed will be submitted to a request URI that is mapped to the controller service.
  • There will be one instance of this service class, which receives and processes all requests that change the state of a user's interaction with the application. This component represents the "controller" component of an MVC architecture.
  • The controller service will select and invoke an action class to perform the requested business logic.
  • The action classes will manipulate the state of the application's interaction with the user, typically by creating or modifying PHPBeans that are stored as request or session attributes (depending on how long they need to be available). Such PHPBeans represent the "model" component of an MVC architecture.
  • Instead of producing the next page of the user interface directly, action classes will generally use the PHRUTS_RequestDispatcher->forward facility of the service API to pass control to an appropriate PHP page to produce the next page of the user interface.

<p>The standard version of PHRUTS_ActionService implements the following logic for each incoming HTTP request. You can override some or all of this functionality by subclassing this service and implementing your own version of the processing.</p>

  • Identify, from the incoming request URI, the substring that will be used to select an action procedure.
  • Use this substring to map to the PHP class name of the corresponding action class (an implementation of the PHRUTS_Action interface).
  • If this is the first request for a particular action class, instantiate an instance of that class and cache it for future use.
  • Optionally populate the properties of a PHRUTS_ActionForm bean associated with this mapping.
  • Call the execute method of this action class, passing on a reference to the mapping that was used (thereby providing access to the underlying PHRUTS_ActionService and PHRUTS_ServiceContext, as well as any specialized properties of the mapping itself), and the request and response that were passed to the controller.

  • author: John WILDENAUER <jwilde@users.sourceforge.net> (PHP4 port of Struts)
  • author: Olivier HENRY <oliv.henry@gmail.com> (PHP5 port of Struts)
  • version: $Id: PHRUTS_ActionService.php,v 1.5 2008/05/28 15:52:26 ohenry Exp $
  • copyright: Copyright PHruts 2008
  • todo: Add information in the class comment about the web deployment descriptor "/WEB-INF/web.xml".
  • todo: Manage the possibility of subclassing the service controller.

Located in /action/PHRUTS_ActionService.php (line 103)


	
			
Variable Summary
Method Summary
PHRUTS_ActionService __construct (PHRUTS_ServiceContext $context)
object getDataSource ( $request, string $key)
void init ()
PHIGEST_Digester initConfigDigester ()
void initInternal ()
PHRUTS_ModuleConfig initModuleConfig (string $prefix, string $paths)
void initModuleDataSources ( $config)
void initModuleMessageResources ( $config)
void initModulePlugIns ( $config)
void initService ()
void process ( $request,  $response)
void __wakeup ()
Variables
static Logger $log = null (line 146)

Logging instance.

  • access: protected
string $config = '/WEB-INF/phruts-config.xml' (line 117)

Comma-separated list of context-relative path(s) to our configuration resource(s) for the default module.

  • access: protected
PHIGEST_Digester $configDigester = null (line 125)

The digester used to produce PHRUTS_ModuleConfig object from a PHruts configuration file.

  • access: protected
array $dataSourceFactories = array() (line 162)

The factories data sources that has been configured for this module, if any.

  • access: protected
PHRUTS_PropertyMessageResources $internal = null (line 132)

The resources object for our internal resources.

  • access: protected
string $internalName = 'phruts::action::ActionResources' (line 139)

The PHP base name of our internal resources.

  • access: protected
PHRUTS_RequestProcessor $processor = null (line 154)

The PHRUTS_RequestProcessor instance we will use to process all incoming requests.

  • access: protected
PHRUTS_ServiceContext $serviceContext = null (line 109)

Service context.

  • access: protected
Methods
Constructor __construct (line 173)
  • access: public
PHRUTS_ActionService __construct (PHRUTS_ServiceContext $context)
getDataSource (line 536)

Return the specified data source for the current module.

  • todo: Throws an exception if key doesn't correspond to a data source.
  • throws: Exception
  • access: public
object getDataSource ( $request, string $key)
  • PHRUTS_HttpServiceRequest $request: The service request we are processing
  • string $key: The key specified in the <data-source> element for the requested data source
getInternal (line 194)

Return the PHRUTS_MessageResources instance containing our internal message strings.

  • access: public
PHRUTS_MessageResources getInternal ()
getModuleConfig (line 483)

Return the module configuration object for the currently selected module.

  • access: protected
PHRUTS_ModuleConfig getModuleConfig ( $request)
getRequestProcessor (line 502)

Look up and return the PHRUTS_RequestProcessor responsible for the specified module, creating a new one if necessary.

  • exception: PHRUTS_ServiceException - If we cannot instantiate a PHRUTS_RequestProcessor instance
  • access: protected
PHRUTS_RequestProcessor getRequestProcessor ( $config)
  • PHRUTS_ModuleConfig $config: The module configuration for which to acquire and return a PHRUTS_RequestProcessor.
getServiceContext (line 184)
  • access: public
PHRUTS_ServiceContext getServiceContext ()
init (line 210)

Initialize this service.

Most of processing has been factored into support methods so that you can override particular functionality at a fairly granular level.

  • exception: PHRUTS_ServiceException - If we cannot configure ourselves correctly
  • access: public
void init ()
initConfigDigester (line 330)

Create (if needed) and return a new PHIGEST_Digester instance that has been initialized to process PHruts module configuration file and configure a corresponding PHRUTS_ModuleConfig object (which must be pushed on to the evaluation stack before parsing begins).

  • return: A new configured PHIGEST_Digester instance.
  • access: protected
PHIGEST_Digester initConfigDigester ()
initInternal (line 255)

Initialize our internal message resources bundle.

  • exception: PHRUTS_ServiceException - If we cannot initialize these resources
  • access: protected
void initInternal ()
initModuleConfig (line 290)

Initialize the application configuration information for the specified module.

  • return: The new module configuration instance.
  • todo: Check if $paths is empty.
  • throws: PHRUTS_ServiceException - If initialization cannot be performed
  • access: protected
PHRUTS_ModuleConfig initModuleConfig (string $prefix, string $paths)
  • string $prefix: Module prefix for this module
  • string $paths: Comma-separated list of context-relative resource path(s) for this module's configuration resource(s).
initModuleDataSources (line 386)

Initialize the data sources for the specified module.

  • throws: PHRUTS_ServiceException - If initialization cannot be performed
  • access: protected
void initModuleDataSources ( $config)
initModuleMessageResources (line 353)

Initialize the application message resources for the specified module.

  • exception: PHRUTS_ServiceException - If initialization cannot be performed
  • access: protected
void initModuleMessageResources ( $config)
initModulePlugIns (line 422)

Initialize the plug ins for the specified module.

  • throws: PHRUTS_ServiceException - If initialization cannot be performed
  • access: protected
void initModulePlugIns ( $config)
initService (line 272)

Initialize global characteristics of the controller service.

  • access: protected
void initService ()
process (line 463)

Perform the standard request processing for this request, and create the corresponding response.

  • throws: PHRUTS_ServiceException
  • access: public
void process ( $request,  $response)
__wakeup (line 164)
  • access: public
void __wakeup ()

Documentation generated on Sat, 31 May 2008 15:45:52 +0200 by phpDocumentor 1.4.1