wCMF  3.6
 All Classes Namespaces Files Functions Variables Groups Pages
Controller Class Reference
+ Inheritance diagram for Controller:

Public Member Functions

 Controller (&$delegate)
 
 initialize (&$request, &$response)
 
 validate ()
 
 hasView ()
 
 execute ()
 
 executeKernel ()
 
 getErrorMsg ()
 
 setErrorMsg ($msg)
 
 appendErrorMsg ($msg)
 
getRequest ()
 
getResponse ()
 
getView ()
 
getDelegate ()
 
 getViewTemplate ($controller, $context, $action)
 
 getCacheId ()
 
 assignViewDefaults (&$view)
 
 isLocalizedRequest ()
 

Public Attributes

 $_request = null
 
 $_response = null
 
 $_errorMsg = ''
 
 $_view = null
 
 $_delegate = null
 

Detailed Description

Controller is the base class of all controllers. If a Controller has a view it is expected to reside in the directory configured in section smarty.templateDir. Additional smarty directories ('templates_c', 'configs', 'cache') are expected in a subdirectory of the template directory named 'smarty'.

wCMF - wemove Content Management Framework Copyright (C) 2005-2014 wemove digital solutions GmbH

Licensed under the terms of any of the following licenses at your choice:

See the license.txt file distributed with this work for additional information.

Id:
class.Controller.php 1462 2014-02-04 23:52:27Z iherwig

Error Handling:

  • use WCMFException::throwEx or action='failure' for fatal errors (displays FailureController)
  • use field _errorMsg for non fatal errors (message will be appended to errorMsg-data which will be displayed in the next view)
Parameters
[in]languageThe language of the requested data, optional
[out]sidThe session id
[out]controllerThe name of the controller
[out]errorMsgAny message set with setErrorMsg or appendErrorMsg, optional
[out]successTrue, if errorMsg is empty or does not exist, False else
Author
ingo herwig ingo@.nosp@m.wemo.nosp@m.ve.co.nosp@m.m

Definition at line 54 of file class.Controller.php.

Member Function Documentation

Controller::Controller ( $delegate)

Constructor.

Parameters
delegateA ControllerDelegate instance, if one is defined in the configuration (optional, default null does not work in PHP4).

Definition at line 67 of file class.Controller.php.

Controller::initialize ( $request,
$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 87 of file class.Controller.php.

References appendErrorMsg().

Referenced by PageExportController\initialize().

+ Here is the call graph for this function:

Controller::validate ( )

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
True/False whether the data are ok or not. In case of False a detailed description is provided by getErrorMsg().

Definition at line 104 of file class.Controller.php.

Referenced by execute().

Controller::hasView ( )

Check if the Controller has a view. Subclasses must implement this method.

Returns
True/False whether the Controller has a view or not.

Definition at line 116 of file class.Controller.php.

References WCMFException\throwEx().

Referenced by execute().

+ Here is the call graph for this function:

Controller::execute ( )

Execute the Controller resulting in its Action processed and/or its View beeing displayed.

Returns
True/False wether following Controllers should be executed or not.

Definition at line 126 of file class.Controller.php.

References assignViewDefaults(), Log\debug(), executeKernel(), Message\get(), getErrorMsg(), ObjectFactory\getInstance(), SessionData\getInstance(), getViewTemplate(), hasView(), Log\isDebugEnabled(), MSG_FORMAT_HTML, Formatter\serialize(), WCMFException\throwEx(), and validate().

+ Here is the call graph for this function:

Controller::executeKernel ( )

Do the work in execute(): Load and process model and maybe asign data to view. Subclasses process their Action and assign the Model to the view.

Returns
False or an an assoziative array with keys 'context' and 'action' describing how to proceed. Return false to break the action processing chain.

Definition at line 211 of file class.Controller.php.

References WCMFException\throwEx().

Referenced by execute().

+ Here is the call graph for this function:

Controller::getErrorMsg ( )

Get a detailed description of the last error.

Returns
The error message.

Definition at line 219 of file class.Controller.php.

References $_errorMsg.

Referenced by execute(), and LoginController\executeKernel().

& Controller::getRequest ( )

Get the Request object.

Returns
A reference to the Request object

Definition at line 248 of file class.Controller.php.

References $_request.

& Controller::getResponse ( )

Get the Response object.

Returns
A reference to the Response object

Definition at line 256 of file class.Controller.php.

References $_response.

& Controller::getView ( )

Get the controller view.

Returns
A reference to the controller view / or null if none is existing

Definition at line 264 of file class.Controller.php.

References $_view.

Referenced by PageExportController\createOutputView().

& Controller::getDelegate ( )

Get the controller delegate.

Returns
A reference to the controller view / or null if none is existing

Definition at line 272 of file class.Controller.php.

References $_delegate.

Controller::getViewTemplate (   $controller,
  $context,
  $action 
)

Get the template filename for the view from the configfile.

Note
static method
Parameters
controllerThe name of the controller
contextThe name of the context
actionThe name of the action
Returns
The filename of the template or false, if now view is defined

Definition at line 284 of file class.Controller.php.

References Log\debug(), WCMFInifileParser\getInstance(), and Log\isDebugEnabled().

Referenced by execute().

+ Here is the call graph for this function:

Controller::getCacheId ( )

Get the id which should be used when caching the controllers view. This method will only be called, if the configuration entry smarty.caching is set to 1. The default implementation returns null. Subclasses should return an id that is unique to each different content of the same view.

Returns
The id or null, if no cache id should be used.

Definition at line 303 of file class.Controller.php.

Controller::assignViewDefaults ( $view)

Assign default variables to the view. This method is called after Controller execution. This method may be used by derived controller classes for convenient View setup.

Parameters
viewA reference to the View to assign the variables to
Attention
Internal use only.

Definition at line 313 of file class.Controller.php.

References Obfuscator\getInstance(), InifileParser\getInstance(), and RightsManager\getInstance().

Referenced by PageExportController\createOutputView(), and execute().

+ Here is the call graph for this function:

Controller::isLocalizedRequest ( )

Check if the current request is localized. This is true, if it has a language parameter that is not equal to Localization::getDefaultLanguage().

Returns
True/False wether the request is localized or not

Definition at line 340 of file class.Controller.php.

References Localization\getInstance().

Referenced by ListboxController\executeKernel(), DeleteController\executeKernel(), TreeViewController\executeKernel(), SaveController\executeKernel(), InsertController\executeKernel(), AsyncPagingController\executeKernel(), DisplayController\executeKernel(), and BatchDisplayController\loadNode().

+ Here is the call graph for this function:

Member Data Documentation

Controller::$_request = null

Definition at line 56 of file class.Controller.php.

Referenced by getRequest().

Controller::$_response = null

Definition at line 57 of file class.Controller.php.

Referenced by getResponse().

Controller::$_errorMsg = ''

Definition at line 59 of file class.Controller.php.

Referenced by getErrorMsg().

Controller::$_view = null

Definition at line 60 of file class.Controller.php.

Referenced by getView().

Controller::$_delegate = null

Definition at line 61 of file class.Controller.php.

Referenced by getDelegate().


The documentation for this class was generated from the following file: