ActionController
Description
Action controller This is the base class for all controllers. Extend ActionController to create a new controller for your application.
Naming conventions
- Controller classes are suffixed by "Controller", naming is regular CamelCase class convention
- Actions are regular camelCase convention
- When creating links with the Request engine, use class and method names eg. createLink('SomeController', 'someAction')
- Views folders and files use the same naming conventions as the classes/methods (eg. view/SomeController/someAction.php)
- The URLs will be lowercase (camelCase is mapped to underscore-separated names)
- You can change the default separator ("_") in the config using the APP_MVC_URL_SEPARATOR constant
- {
- function __construct()
- {
- parent::__construct();
- }
- function index() {} // mapped by /home/index/
- function anotherAction() {} // mapped by /home/another_action/
- }
Located in /mvc/libraries/ActionController.class.php (line 42)
Variable Summary
Method Summary
void
onConstruct
()
Variables
mixed
$controllerName
(line 52)
Current controller name
string
$defaultAction
= APP_MVC_DEFAULT_ACTION (line 48)
Overrride this to define the controller's default action name
RequestEngineMVC
$request
(line 66)
ResponseEngine
$response
(line 74)
SessionEngine
$session
(line 70)
Methods
addFilter (line 139)
Add a filter to the curent controller Typically you should call that in your controller's onConstruct() method
Example:
- {
- //...
- function onConstruct()
- {
- }
- //...
- }
- Filterable $filter
chainAction (line 156)
Executes an action from within another action
void
chainAction
( $controllerName, $actionName)
- $controllerName
- $actionName
chainActionAndView (line 172)
Executes an action from within another action and override the view from the first action
void
chainActionAndView
( $controllerName, $actionName, [ $resetViews = true])
- $controllerName
- $actionName
- $resetViews
onConstruct (line 120)
Stuff to be executed when the controller is instanciated; override this in your controllers
void
onConstruct
()