Detailed Description
Controller is the base class of all controllers.
Error Handling:
- throw an Exception or use response action failure to signal fatal errors (calls wcmf::application::controller::FailureController)
- add an ApplicationError to the response to signal non fatal errors
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 |
Definition at line 48 of file Controller.php.
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 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
-
$request A 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. $response A 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.
|
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
-
$method The name of the method to execute (optional, defaults to 'doExecute' if not given)
Definition at line 126 of file Controller.php.
|
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
-
$action The name of the action to execute
- Returns
- Response instance
Definition at line 172 of file Controller.php.
getRequest | ( | ) |
getResponse | ( | ) |
|
protected |
|
protected |
|
protected |
Get the PersistenceFacade instance.
- Returns
- PersistenceFacade
Definition at line 222 of file Controller.php.
|
protected |
Get the PermissionManager instance.
- Returns
- PermissionManager
Definition at line 230 of file Controller.php.
|
protected |
|
protected |
|
protected |
|
protected |
|
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.
|
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.
|
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.