Actions

Yii: Difference between revisions

From LimeSurvey Manual

No edit summary
 
Line 8: Line 8:
First some useful links:
First some useful links:


[http://www.yiiframework.com/doc/guide/ Userguide of the Yii framework]
[https://www.yiiframework.com/doc/guide/1.1/ Userguide of the Yii framework v1.1]


[http://www.yiiframework.com/wiki/83/netbeans-ide-and-yii-projects/ Some hints on code completion in NetBeans IDE]
[http://www.yiiframework.com/wiki/83/netbeans-ide-and-yii-projects/ Some hints on code completion in NetBeans IDE]

Latest revision as of 15:26, 11 May 2022

Yii

Table of contents:{toc}

This page is intended to help people get started on the Yii branch of the code and to provide some guidance in coding. At the moment I am just getting started with the branch myself and run into some stuff I think needs to be adressed. Please feel free to help improve this page and correct me if I'm wrong ;-)

First some useful links:

Userguide of the Yii framework v1.1

Some hints on code completion in NetBeans IDE

Controllers

Most important stuff to know is in [1] where the basics of controllers / actions are described.

For LimeSurvey we use our own controller class LSYii_Controller to extend instead of the CController class. This helps us by providing the necessary libraries and some convenience methods and it also helps to have a single point to inject future extensions.

Actions

In Yii controllers can encapsulate actions when we use a method with a special name that is prefixed with 'action'. So a method actionSubmit would be the submit action. Actions can also be separated from their controller for various reasons. In LimeSurvey we try to do this as much as possible, placing the action classes in a subdirectory below the controllers directory with the lowercased name of the controller they belong to.

Inline documentation

To help our fellow coders understand what a method is supposed to do, we try to document using docblocks as much as possible. Providing type hints on return values helps in most IDE for code completion. Sometimes working like this can feel like more typing for the coder who knows his way around the code but for other who are not familiar with the code it can be of great value. So please document as much as possible.