new mmir.ctrl.Controller(name, jsonDef, instanceConstr)
The Controller Class is a kind of interface-class which gives access to the methods of a controller and its helper.
Also holds information about views and partials associated with the controller.
Also holds information about views and partials associated with the controller.
Name | Type | Description |
---|---|---|
name |
String | Name of the Controller |
jsonDef |
Object | Information about the controllers, views, and partials |
instanceConstr |
function | the constructor for creating a new controller instance |
Members
-
defObject
-
The json definition of the views and partials associated with the controller. Also contains paths to controller and its views/partials.
-
helpermmir.ctrl.Helper
-
The instance of the with the controller associated helper.
-
protectedimplObject
-
The definition of the controller object, i.e. its (application specific) implementation, containing all properties and functions of the controller.
A method of the controller implementation can be called via:this.instance.method(parameter);
-
layoutObject
-
The layout (info) for this controller (if undefined, the default layout should be used)
-
nameString
-
The name of the controller.
-
An array holding the names of all partials associated with the controller.
-
protectedscript
-
- Deprecated
- use
impl
instead
- use
-
An array holding the names of all views associated with the controller.
Methods
-
getHelper(){mmir.ctrl.Helper}
-
Returns the helper of the controller instance.
Returns:
Type Description mmir.ctrl.Helper The helper instance -
getLayout(){Object}
-
Returns the layout of the controller instance. If undefined, the default layout should be used. TODO should this be private/hidden? -> provides "internal" JSON-details object (used in PresentationManager) The info object has properties: {String} name {String} path {String} fileName
Returns:
Type Description Object The controller's layout (may be undefined) -
getLayoutName(){String}
-
Returns the layout name for the controller instance. This is equal to the controller name. If undefined, the default layout should be used.
Returns:
Type Description String The controller's layout name (may be undefined) -
getName(){String}
-
Returns the name of the controller instance.
Returns:
Type Description String The name of the controller -
Returns the partial names for the controller instance.
Returns:
Type Description Array.<String> An array of the names of the controller's partials -
Returns the partial info object for the controller instance. TODO should this be private/hidden? -> provides "internal" JSON-details object (used in PresentationManager) Each info object has properties: {String} name {String} path
Returns:
Type Description Array.<Object> An array of the controller's partials -
Returns the view names for the controller instance.
Returns:
Type Description Array.<String> An array of the names of the controller's views -
Returns the view names for the controller instance. TODO should this be private/hidden? -> provides "internal" JSON-details object (used in PresentationManager) Each info object has properties: {String} name {String} path
Returns:
Type Description Array.<Object> An array of the controller's views -
protectedloadHelper(name, helperPath, ctx)
-
This function loads the helper of the controller - if it exists.
Name Type Description name
String Name of the Helper to be loaded helperPath
String Path to the helper file to load ctx
Object the context for the helper implementation, i.e. where the constructor (will) exists: ctx. () -
parsePartials(partialDefs)
-
Stores all names of the partials of the controller by iterating over the array of the partials definition.
This function is called by the constructor of themmir.ctrl.Controller
class.Name Type Description partialDefs
Array Array of the json-definition of the controllers partials - containing name of the partials and their corresponding path to the js-files -
parseViews(viewDefs)
-
Stores all names of the views of the controller by iterating over the array of the views definition.
This function is called by the constructor of themmir.ctrl.Controller
class.Name Type Description viewDefs
Array Array of the json-definition of the controllers views - containing name of the views and their corresponding path to the js-files -
perform(actionName, data){Object}
-
This function performs an action of a controller - which is represented by this instance of the Controller
class - by calling the method from the corresponding controller, e.g. assets/www/controllers/application.jsName Type Description actionName
String Name of the method to be executed data
Object Data to pass to the method of the controller as argument Returns:
Type Description Object The return value of the executed method -
performHelper(actionName, data){Object}
-
This function performs a helper action of a controller by calling the appropriate method
mmir.ctrl.Helper#perform
of the instance of the helper class associated with the controller.Name Type Description actionName
String Name of the helper method to be executed data
Object Data to pass to the helper method as argument Returns:
Type Description Object The return value of the executed method -
performIfPresent(actionName, data){Object}
-
This function performs an action of a controller, but only if an action with this name exists; otherwise nothing is done. In difference to perform(..), the method does not trigger an ERROR, if the action does not exist / is not implemented. As a consequence, this method refers to "optionally" implemented functions, whereas perform(..) refers to mandatory functions.
Name Type Description actionName
String Name of the method to be executed data
Object Data to pass to the method of the controller as argument Returns:
Type Description Object The return value of the executed method