Controllers execute the user-defined actions. In order to implement custom controllers a class must be derived from the baseclass Controller, which implements the methods Controller::hasView and Controller::executeKernel.
The associative array _data provides all data of the preceeding view's input fields to the controller. The names of the input fields form the keys of the array. The controller in turn can pass data to the view. The view - if existent - is accessible via the _view variable, data can be assigned by the methods assign and assign_by_ref.
The method Controller::hasView returns true or false, whether a view is displayed or not (the return value can differ depending on the context or action, for an example see
LoginController).
The method Controller::executeKernel executes the actual action. In this method application data is loaded, modified, created, deleted and where required passed to the view for display. The method either returns false, which means, that the
ActionMapper should call no further controller or a context and action, from which the
ActionMapper determines the next controller (see
ActionKeys). This means if a view should be displayed, the method must return false.
While programming custom controllers often the methods Controller::initialize and Controller::validate are overridden in order to carry out initializations or to validate provided data.
if you manually write a controller keep in mind how to write a file that is not overwritten by the generator
<!-- PROTECTED REGION ID(application/include/controller/class.Name.php/Body) START -->
//my code
<!-- PROTECTED REGION END -->
Additionally meanfully
heads help to understand the function of the
controller.
The framework's controllers are located in the directory /wcmf/application/controller.
To start with programming check this example:
Controller