ManiaLib 1.0b1 API Reference

 Class 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
Example
  1.  class HomeController extends ActionController
  2.  {
  3.     function __construct()
  4.     {
  5.         parent::__construct();
  6.         $this->addFilter(new RegisterRequestParametersFilter());
  7.     }
  8.  
  9.     function index({// mapped by /home/index/
  10.  
  11.     function anotherAction({// mapped by /home/another_action/
  12.  }

Located in /mvc/libraries/ActionController.class.php (line 42)


	
			
Variable Summary
Method Summary
 void addFilter (Filterable $filter)
 void chainAction ( $controllerName,  $actionName)
 void chainActionAndView ( $controllerName,  $actionName, [ $resetViews = true])
 void onConstruct ()
Variables
mixed $controllerName (line 52)

Current controller name

  • access: protected
string $defaultAction = APP_MVC_DEFAULT_ACTION (line 48)

Overrride this to define the controller's default action name

  • access: protected
RequestEngineMVC $request (line 66)
  • access: protected
ResponseEngine $response (line 74)
  • access: protected
SessionEngine $session (line 70)
  • access: protected
Methods
addFilter (line 139)

Add a filter to the curent controller Typically you should call that in your controller's onConstruct() method

Example:

  1.  class SomeStuffController extends ActionController
  2.  {
  3.      //...
  4.      function onConstruct()
  5.      {
  6.             $this->addFilter(new UserAgentCheckFilter());
  7.      }
  8.      //...
  9.  }

  • access: protected
void addFilter (Filterable $filter)
chainAction (line 156)

Executes an action from within another action

  • access: protected
void chainAction ( $controllerName,  $actionName)
  • $controllerName
  • $actionName
chainActionAndView (line 172)

Executes an action from within another action and override the view from the first action

  • access: protected
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

  • access: protected
void onConstruct ()