[TYPO3-ect] Draft: Specification of Dispatch and Action Controller Framework
Elmar Hinz
elmar.DOT.hinz at team.MINUS.red.DOT.net
Fri Mar 24 07:35:35 CET 2006
Hello Typonics,
this is the conception of the controller framework I am currently
working on. It is an extension of the action controller proposed by
Michael Scharkow.
It is meant as a "first" framework for the time after pi_base. You can
define other extension frameworks. The target of this one is, to show
that it is possible at all to build extensions without pi_base.
Other components will belong to this framework to replace all the
function of pi_base, like tx_lib_link or a few spl interfaces
desingned as extensible classes that also work with PHP4.
This part of the framework specification concentrates on the controller.
Actual versions will be part of tx_lib/doc/manual.sxw.
=====================================================================
The Dispatch and Action Controller Framework
Tasks of a Controller
The controller organizes the things to go the way they should. It is a
department manager that is called by the outer framework to organize
an order and to give back the result. The controller makes necessary
decisions, coordinates model and view, controlls the workflow and
returns the result in the end.
Switching
The first step every controller does, is to switch the incomming
request to an appropriate controller subpart that is programmed for
the requierements of the request. It is typically indicated by
parameters that are send with the request, wich subpart should be run.
The subpart and the parameters are called action.
You can place an additional switch before the controllers that selects
the controller itself. It's a kind of a super manager to organize
bigger projects. This precontroller is called dispatch controller and
the steering parameter is called controller. In theory it is possible
to build an unlimited hierarchy of dispatch controllers by setting
additional parameter names. You probably will never do this.
Both types of controllers are created by inheritance from a library
class, he class of the action controller is tx_lib_actionController,
the class of the dispatch controller is tx_lib_dispatchController.
Location
All controllers are placed in the directory controllers of an extension.
The Action Controller
The action controller is steered by the parameter action and calls a
method of the same name with the suffix "Action". If the parameter
value is "sendPdf" the method "sendPdfAction" is called to handle the
request.
If no action is send, the action "defaultAction" is called. You can
set an other name for the default action like "indexAction".
If an unknown action is called the action "unknownAction" is called.
By default this action sends the header 404. You could alter the
action to give back an informational text or to throw an error.
You can overwrite the default names of the action parameter, the
action suffix, the default action and the unknown Action.
The DispatchController
The dispatch controller is steered by the parameter controller and
calls an ation controller class of an matching name. If the parameter
value is "edit" the class tx_myext_controllers_edit is called to
handle the request.
You can add new action controllers in extensions. If the parameter
"plusExt__edit" (double underscore) is given then the class
tx_plusExt_controllers_edit is called. It is a shortcut for
"plusExt_controllers_edit" which would also work. If an controller
stays in the "irregular" extension directoy abc/xyz the parameter has
to be "plusExt_abc_xyz_edit". If the controller stays in the extension
main directory the parameter is "plusExt_edit" (single underscore).
More information about the TYPO3-team-extension-coordination
mailing list