Controllers in Zupal
Zupal has a native class that extends Zend_Controller_Action. While extending Zupal_Controller_Abstract is not REQURED to create a controller in Zupal, it does let you write a seperate class for handling each action. This is "Syntax sugar" that lets you manage an action's response in a class, rather than a method of a controller. This makes it a little easier to manage actions -- individual developers can write action handlers without worrying about SVN conflicts, and your controller doesn't get thousands of lines deep.
In order to enable extensions to handle an action, create a folder with the controller's name (capitalized) in the controller directory and creatting a class with in a file [action]Action.php that extends Zupal_Controller_Action_Abstract. The actual handling method is "execute() (no parameters).
For instance, say you have a module "Leads" and a controller "Leads_ReportController" (in modules/leads/controllers/ReportsController.php). If you want to create an action that responds to /leads/report/create you can of course create an action "createAction()" in the controller, but you could also create an extending class for Zupal_Controller_Action_Abstract in /modules/leads/controllers/Reports/CreateAction.php and put the satisfying code in the execute method thereof.
Using an extension class doesn't change the pathing or methodology of views.
Errors and Messages
Zend_Controller_Abstract automatically sets the view placeholder tokens "error" and "message" for use in the zupal templates.

Post new comment