Zend Framework
1.12
|
Public Member Functions | |
__construct (Zend_Controller_Request_Abstract $request, Zend_Controller_Response_Abstract $response, array $invokeArgs=array()) | |
Class constructor. | |
init () | |
Initialize object. | |
initView () | |
Initialize View object. | |
render ($action=null, $name=null, $noController=false) | |
Render a view. | |
renderScript ($script, $name=null) | |
Render a given view script. | |
getViewScript ($action=null, $noController=null) | |
Construct view script path. | |
getRequest () | |
Return the Request object. | |
setRequest (Zend_Controller_Request_Abstract $request) | |
Set the Request object. | |
getResponse () | |
Return the Response object. | |
setResponse (Zend_Controller_Response_Abstract $response) | |
Set the Response object. | |
getInvokeArgs () | |
Return the array of constructor arguments (minus the Request object) | |
getInvokeArg ($key) | |
Return a single invocation argument. | |
getHelper ($helperName) | |
Get a helper by name. | |
getHelperCopy ($helperName) | |
Get a clone of a helper by name. | |
setFrontController (Zend_Controller_Front $front) | |
Set the front controller instance. | |
getFrontController () | |
Retrieve Front Controller. | |
preDispatch () | |
Pre-dispatch routines. | |
postDispatch () | |
Post-dispatch routines. | |
__call ($methodName, $args) | |
Proxy for undefined methods. | |
dispatch ($action) | |
Dispatch the requested action. | |
run (Zend_Controller_Request_Abstract $request=null, Zend_Controller_Response_Abstract $response=null) | |
Call the action specified in the request object, and return a response. | |
getParam ($paramName, $default=null) | |
Gets a parameter from the Request object. | |
setParam ($paramName, $value) | |
Set a parameter in the Request object. | |
hasParam ($paramName) | |
Determine whether a given parameter exists in the Request object. | |
getAllParams () | |
Return all parameters in the Request object as an associative array. | |
forward ($action, $controller=null, $module=null, array $params=null) | |
Forward to another controller/action. | |
redirect ($url, array $options=array()) | |
Redirect to another URL. | |
Public Attributes | |
$viewSuffix = 'phtml' | |
$view | |
Protected Member Functions | |
_setInvokeArgs (array $args=array()) | |
Set invocation arguments. | |
_getParam ($paramName, $default=null) | |
Gets a parameter from the Request object. | |
_setParam ($paramName, $value) | |
Set a parameter in the Request object. | |
_hasParam ($paramName) | |
Determine whether a given parameter exists in the Request object. | |
_getAllParams () | |
Return all parameters in the Request object as an associative array. | |
_forward ($action, $controller=null, $module=null, array $params=null) | |
Forward to another controller/action. | |
_redirect ($url, array $options=array()) | |
Redirect to another URL. | |
Protected Attributes | |
$_classMethods | |
$_delimiters | |
$_invokeArgs = array() | |
$_frontController | |
$_request = null | |
$_response = null | |
$_helper = null | |
__construct | ( | Zend_Controller_Request_Abstract | $request, |
Zend_Controller_Response_Abstract | $response, | ||
array | $invokeArgs = array() |
||
) |
Class constructor.
The request and response objects should be registered with the controller, as should be any additional optional arguments; these will be available via getRequest(), getResponse(), and getInvokeArgs(), respectively.
When overriding the constructor, please consider this usage as a best practice and ensure that each is registered appropriately; the easiest way to do so is to simply call parent::__construct($request, $response, $invokeArgs).
After the request, response, and invokeArgs are set, the helper broker is initialized.
Finally, init() is called as the final action of instantiation, and may be safely overridden to perform initialization tasks; as a general rule, override init() instead of the constructor to customize an action controller's instantiation.
Zend_Controller_Request_Abstract | $request | |
Zend_Controller_Response_Abstract | $response | |
array | $invokeArgs | Any additional invocation arguments |
Implements Zend_Controller_Action_Interface.
__call | ( | $methodName, | |
$args | |||
) |
Proxy for undefined methods.
Default behavior is to throw an exception on undefined methods, however this function can be overridden to implement magic (dynamic) actions, or provide run-time dispatching.
string | $methodName | |
array | $args |
Zend_Controller_Action_Exception |
|
finalprotected |
Forward to another controller/action.
It is important to supply the unformatted names, i.e. "article" rather than "ArticleController". The dispatcher will do the appropriate formatting when the request is received.
If only an action name is provided, forwards to that action in this controller.
If an action and controller are specified, forwards to that action and controller in this module.
Specifying an action, controller, and module is the most specific way to forward.
A fourth argument, $params, will be used to set the request parameters. If either the controller or module are unnecessary for forwarding, simply pass null values for them before specifying the parameters.
string | $action | |
string | $controller | |
string | $module | |
array | $params |
|
protected |
Return all parameters in the Request object as an associative array.
|
protected |
Gets a parameter from the Request object.
If the parameter does not exist, NULL will be returned.
If the parameter does not exist and $default is set, then $default will be returned instead of NULL.
string | $paramName | |
mixed | $default |
|
protected |
Determine whether a given parameter exists in the Request object.
string | $paramName |
|
protected |
Redirect to another URL.
Proxies to Zend_Controller_Action_Helper_Redirector::gotoUrl().
string | $url | |
array | $options | Options to be used when redirecting |
|
protected |
|
protected |
Set a parameter in the Request object.
string | $paramName | |
mixed | $value |
dispatch | ( | $action | ) |
Dispatch the requested action.
string | $action | Method name of action |
Implements Zend_Controller_Action_Interface.
|
final |
Forward to another controller/action.
It is important to supply the unformatted names, i.e. "article" rather than "ArticleController". The dispatcher will do the appropriate formatting when the request is received.
If only an action name is provided, forwards to that action in this controller.
If an action and controller are specified, forwards to that action and controller in this module.
Specifying an action, controller, and module is the most specific way to forward.
A fourth argument, $params, will be used to set the request parameters. If either the controller or module are unnecessary for forwarding, simply pass null values for them before specifying the parameters.
string | $action | |
string | $controller | |
string | $module | |
array | $params |
getAllParams | ( | ) |
Return all parameters in the Request object as an associative array.
getFrontController | ( | ) |
Retrieve Front Controller.
getHelper | ( | $helperName | ) |
getHelperCopy | ( | $helperName | ) |
Get a clone of a helper by name.
string | $helperName |
getInvokeArg | ( | $key | ) |
Return a single invocation argument.
string | $key |
getInvokeArgs | ( | ) |
Return the array of constructor arguments (minus the Request object)
getParam | ( | $paramName, | |
$default = null |
|||
) |
Gets a parameter from the Request object.
If the parameter does not exist, NULL will be returned.
If the parameter does not exist and $default is set, then $default will be returned instead of NULL.
string | $paramName | |
mixed | $default |
getRequest | ( | ) |
Return the Request object.
getResponse | ( | ) |
Return the Response object.
getViewScript | ( | $action = null , |
|
$noController = null |
|||
) |
Construct view script path.
Used by render() to determine the path to the view script.
string | $action | Defaults to action registered in request object |
bool | $noController | Defaults to false; i.e. use controller name as subdir in which to search for view script |
Zend_Controller_Exception | with bad $action |
hasParam | ( | $paramName | ) |
Determine whether a given parameter exists in the Request object.
string | $paramName |
init | ( | ) |
initView | ( | ) |
Initialize View object.
Initializes $view if not otherwise a Zend_View_Interface.
If $view is not otherwise set, instantiates a new Zend_View object, using the 'views' subdirectory at the same level as the controller directory for the current module as the base directory. It uses this to set the following:
Zend_Controller_Exception | if base view directory does not exist |
postDispatch | ( | ) |
Post-dispatch routines.
Called after action method execution. If using class with Zend_Controller_Front, it may modify the Request object and reset its dispatched flag in order to process an additional action.
Common usages for postDispatch() include rendering content in a sitewide template, link url correction, setting headers, etc.
preDispatch | ( | ) |
Pre-dispatch routines.
Called before action method. If using class with Zend_Controller_Front, it may modify the Request object and reset its dispatched flag in order to skip processing the current action.
redirect | ( | $url, | |
array | $options = array() |
||
) |
Redirect to another URL.
Proxies to Zend_Controller_Action_Helper_Redirector::gotoUrl().
string | $url | |
array | $options | Options to be used when redirecting |
render | ( | $action = null , |
|
$name = null , |
|||
$noController = false |
|||
) |
Render a view.
Renders a view. By default, views are found in the view script path as <controller>/<action>.phtml. You may change the script suffix by resetting $viewSuffix. You may omit the controller directory prefix by specifying boolean true for $noController.
By default, the rendered contents are appended to the response. You may specify the named body content segment to set by specifying a $name.
string | null | $action | Defaults to action registered in request object |
string | null | $name | Response object named path segment to use; defaults to null |
bool | $noController | Defaults to false; i.e. use controller name as subdir in which to search for view script |
renderScript | ( | $script, | |
$name = null |
|||
) |
Render a given view script.
Similar to render(), this method renders a view script. Unlike render(), however, it does not autodetermine the view script via getViewScript(), but instead renders the script passed to it. Use this if you know the exact view script name and path you wish to use, or if using paths that do not conform to the spec defined with getViewScript().
By default, the rendered contents are appended to the response. You may specify the named body content segment to set by specifying a $name.
string | $script | |
string | $name |
run | ( | Zend_Controller_Request_Abstract | $request = null , |
Zend_Controller_Response_Abstract | $response = null |
||
) |
Call the action specified in the request object, and return a response.
Not used in the Action Controller implementation, but left for usage in Page Controller implementations. Dispatches a method based on the request.
Returns a Zend_Controller_Response_Abstract object, instantiating one prior to execution if none exists in the controller.
preDispatch() is called prior to the action, postDispatch() is called following it.
null | Zend_Controller_Request_Abstract | $request | Optional request object to use |
null | Zend_Controller_Response_Abstract | $response | Optional response object to use |
setFrontController | ( | Zend_Controller_Front | $front | ) |
Set the front controller instance.
Zend_Controller_Front | $front |
setParam | ( | $paramName, | |
$value | |||
) |
Set a parameter in the Request object.
string | $paramName | |
mixed | $value |
setRequest | ( | Zend_Controller_Request_Abstract | $request | ) |
Set the Request object.
Zend_Controller_Request_Abstract | $request |
setResponse | ( | Zend_Controller_Response_Abstract | $response | ) |
Set the Response object.
Zend_Controller_Response_Abstract | $response |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
$view |
$viewSuffix = 'phtml' |