Class Controller
Defined in: controller.js.
Constructor Attributes | Constructor Name and Description |
---|---|
Controller(name, jsonDef)
The Controller Class is a kind of interface-class which gives access to the methods of a controller and its helper.
|
Method Attributes | Method Name and Description |
---|---|
Returns the helper of the controller instance.
|
|
Returns the layout of the controller instance.
|
|
Returns the layout name for the controller instance.
|
|
getName()
Returns the name of the controller instance.
|
|
Returns the partial names for the controller instance.
|
|
Returns the partial info object for the controller instance.
|
|
Returns the view names for the controller instance.
|
|
getViews()
Returns the view names for the controller instance.
|
|
loadHelper(name, helperPath)
This function loads the helper of the controller - if it exists.
|
|
parsePartials(partialDefs)
Stores all names of the partials of the controller by iterating over the array of the partials definition.
|
|
parseViews(viewDefs)
Stores all names of the views of the controller by iterating over the array of the views definition.
|
|
perform(actionName, data)
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. |
|
performHelper(actionName, data)
This function performs a helper action of a controller by calling the appropriate method
Helper#perform of the instance of the helper class associated with the controller. |
|
performIfPresent(actionName, data)
This function performs an action of a controller, but only if an action with this name exists; otherwise nothing is done.
|
Class Detail
Controller(name, jsonDef)
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.
- Parameters:
- {String} name
- Name of the Controller
- {Object} jsonDef
- Information about the controllers views and partials
Method Detail
{Object}
getHelper()
Returns the helper of the controller instance.
- Returns:
- {Object} The helper instance
{Object}
getLayout()
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:
- {Object} The controller's layout (may be undefined)
{String}
getLayoutName()
Returns the layout name for the controller instance.
This is equal to the controller name.
If undefined, the default layout should be used.
- Returns:
- {String} The controller's layout name (may be undefined)
{String}
getName()
Returns the name of the controller instance.
- Returns:
- {String} The name of the controller
{Array}
getPartialNames()
Returns the partial names for the controller instance.
- Returns:
- {Array
} An array of the controllers partials
{Array
getPartials()
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:
- {Array An array of the controllers partials
{Array}
getViewNames()
Returns the view names for the controller instance.
- Returns:
- {Array
} An array of the controllers views
{Array
getViews()
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:
- {Array An array of the controllers views
loadHelper(name, helperPath)
This function loads the helper of the controller - if it exists.
- Parameters:
- {String} name
- Name of the Helper to be loaded
- {String} helperPath
- Path to the helper file to load
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 the mmir.Controller class.
This function is called by the constructor of the mmir.Controller class.
- Parameters:
- {Array} partialDefs
- 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 the mmir.Controller class.
This function is called by the constructor of the mmir.Controller class.
- Parameters:
- {Array} viewDefs
- Array of the json-definition of the controllers views - containing name of the views and their corresponding path to the js-files
{Object}
perform(actionName, data)
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.js
class - by calling the method from the corresponding controller, e.g. assets/www/controllers/application.js
- Parameters:
- {String} actionName
- Name of the method to be executed
- {Object} data
- Data to pass to the method of the controller as argument
- Returns:
- {Object} The return value of the executed method
{Object}
performHelper(actionName, data)
This function performs a helper action of a controller by calling the appropriate method
Helper#perform of the instance of the helper class associated with the controller.
Helper#perform of the instance of the helper class associated with the controller.
- Parameters:
- {String} actionName
- Name of the helper method to be executed
- {Object} data
- Data to pass to the helper method as argument
- Returns:
- {Object} The return value of the executed method
{Object}
performIfPresent(actionName, data)
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.
- Parameters:
- {String} actionName
- Name of the method to be executed
- {Object} data
- Data to pass to the method of the controller as argument
- Returns:
- {Object} The return value of the executed method