Detailed Description

Controller is the base class of all controllers.

Error Handling:

The following default request/response parameters are defined:

Parameter Description
in / out action The action to be executed
in / out context The context of the action
in language The language of the requested data (optional)
out controller The name of the executed controller
out success Boolean whether the action completed successfully or not (depends on existence of error messages)
out errorMessage An error message which is displayed to the user
out errorCode An error code, describing the type of error
out errorData Some error codes require to transmit further information to the client
Author
ingo herwig ingo@.nosp@m.wemo.nosp@m.ve.co.nosp@m.m

Definition at line 48 of file Controller.php.

+ Inheritance diagram for Controller:

Public Member Functions

 __construct (Session $session, PersistenceFacade $persistenceFacade, PermissionManager $permissionManager, ActionMapper $actionMapper, Localization $localization, Message $message, Configuration $configuration)
 
 initialize (Request $request, Response $response)
 
 execute ($method=null)
 
 getRequest ()
 
 getResponse ()
 

Protected Member Functions

 validate ()
 
 executeSubAction ($action)
 
 getLogger ()
 
 getSession ()
 
 getPersistenceFacade ()
 
 getPermissionManager ()
 
 getActionMapper ()
 
 getLocalization ()
 
 getMessage ()
 
 getConfiguration ()
 
 assignResponseDefaults ()
 
 isLocalizedRequest ()
 
 checkLanguageParameter ()
 

Constructor & Destructor Documentation

__construct ( Session  $session,
PersistenceFacade  $persistenceFacade,
PermissionManager  $permissionManager,
ActionMapper  $actionMapper,
Localization  $localization,
Message  $message,
Configuration  $configuration 
)

Constructor.

Parameters
$session
$persistenceFacade
$permissionManager
$actionMapper
$localization
$message
$configuration

Definition at line 72 of file Controller.php.

Member Function Documentation

initialize ( Request  $request,
Response  $response 
)

Initialize the Controller with request/response data.

Which data is required is defined by the Controller. The base class method just stores the parameters in a member variable. Specialized Controllers may overide this behaviour for further initialization.

Attention
It lies in its responsibility to fail or do some default action if some data is missing.
Parameters
$requestA reference to the Request sent to the Controller. The sender attribute of the Request is the last controller's name, the context is the current context and the action is the requested one. All data sent from the last controller are accessible using the Request::getValue method. The request is supposed to be read-only. It will not be used any more after beeing passed to the controller.
$responseA reference to the Response that will be modified by the Controller. The initial values for context and action are the same as in the request parameter and are meant to be modified according to the performed action. The sender attribute of the response is set to the current controller. Initially there are no data stored in the response.

Definition at line 103 of file Controller.php.

validate ( )
protected

Check if the data given by initialize() meet the requirements of the Controller.

Subclasses will override this method to validate against their special requirements.

Returns
Boolean whether the data are ok or not.

Definition at line 116 of file Controller.php.

execute (   $method = null)

Execute the Controller resulting in its action processed.

The actual processing is delegated to the given method, which must be implemented by concrete Controller subclasses.

Parameters
$methodThe name of the method to execute (optional, defaults to 'doExecute' if not given)

Definition at line 126 of file Controller.php.

executeSubAction (   $action)
protected

Delegate the current request to another action.

The context is the same as the current context and the source controller will be set to this. The request and response format will be NullFormat which means that all request values should be passed in the application internal format and all response values will have that format.

Parameters
$actionThe name of the action to execute
Returns
Response instance

Definition at line 172 of file Controller.php.

getRequest ( )

Get the Request instance.

Returns
Request

Definition at line 190 of file Controller.php.

getResponse ( )

Get the Response instance.

Returns
Response

Definition at line 198 of file Controller.php.

getLogger ( )
protected

Get the Logger instance.

Returns
Logger

Definition at line 206 of file Controller.php.

getSession ( )
protected

Get the Session instance.

Returns
Session

Definition at line 214 of file Controller.php.

getPersistenceFacade ( )
protected

Get the PersistenceFacade instance.

Returns
PersistenceFacade

Definition at line 222 of file Controller.php.

getPermissionManager ( )
protected

Get the PermissionManager instance.

Returns
PermissionManager

Definition at line 230 of file Controller.php.

getActionMapper ( )
protected

Get the ActionMapper instance.

Returns
ActionMapper

Definition at line 238 of file Controller.php.

getLocalization ( )
protected

Get the Localization instance.

Returns
Localization

Definition at line 246 of file Controller.php.

getMessage ( )
protected

Get the Message instance.

Returns
Message

Definition at line 254 of file Controller.php.

getConfiguration ( )
protected

Get the Configuration instance.

Returns
Configuration

Definition at line 262 of file Controller.php.

assignResponseDefaults ( )
protected

Assign default variables to the response.

This method is called after Controller execution. This method may be used by derived controller classes for convenient response setup.

Definition at line 270 of file Controller.php.

isLocalizedRequest ( )
protected

Check if the current request is localized.

This is true, if it has a language parameter that is not equal to Localization::getDefaultLanguage(). Throws an exception if a language is given which is not supported

Returns
Boolean whether the request is localized or not

Definition at line 300 of file Controller.php.

checkLanguageParameter ( )
protected

Checks the language request parameter and adds an response error, if it is not contained in the Localization::getSupportedLanguages() list.

Returns
Boolean

Definition at line 315 of file Controller.php.