This manual is deprecated. Please visit https://groupoffice.readthedocs.io for the latest documentation. |
Controllers
A controller is a class that contains actions. Actions can be executed by a HTTP call or the Command Line Interface.
For example if you would like to create an action for a notes store you would create this controller:
<?php class GO_Notes_Controller_Note extends GO_Base_Controller_AbstractController{ protected function actionStore($params){ return array("success"=>true); } }
The character case of the names are very important. The name of the module must start with a capital and all other characters are lowercase. The name after "GO_Notes_Controller_" can be anything but should start with a capital. The filename of the controller must match the case. In this case it would be "modules/notes/controller/NoteController.php"
Calling actions
Actions are called with a route parameter "r". The route is build up like this:
<MODULE>/<CONTROLLER>/<ACTION>
The <MODULE> part is omitted for core controllers that can be found in the "controller" folder in the root of Group-Office.
The actionStore function in the example code above is now callable with URL:
http://localhost/groupoffice/index.php?r=notes/note/store
All $_REQUEST parameters are passed with the $params variable. Typically actions return an array that will be converted to JSON. A success parameter must be passed. If success = false, then a feedback parameter is required too with the error message.