Abstract Class Zend_Controller_Action

Description
  • copyright: Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
  • abstract:
  • license: New BSD License

Located in /Controller/Action.php (line 44)


	
			
Variable Summary
Method Summary
 void __construct (Zend_Controller_Request_Abstract $request, Zend_Controller_Response_Abstract $response, [ $invokeArgs = array()])
 void dispatch (string $action)
 mixed getInvokeArg (string $key)
 array getInvokeArgs ()
 string getViewScript ([string $action = null], [bool $noController = false])
 void init ()
 void postDispatch ()
 void preDispatch ()
 void render ([string|null $action = null], [string|null $name = null], [bool $noController = false])
 void _forward (string $action, [string $controller = null], [string $module = null], [ $params = null])
 array _getAllParams ()
 mixed _getParam (string $paramName, [mixed $default = null])
 boolean _hasParam (string $paramName)
 void _redirect (string $url, [ $options = array()])
 Zend_Controller_Action _setInvokeArgs ([ $args = array()])
 Zend_Controller_Action _setParam (string $paramName, mixed $value)
 void __call (string $methodName, array $args)
Variables
Zend_View_Interface $view (line 82)

View object

  • access: public
string $viewSuffix = 'phtml' (line 76)

View script suffix; defaults to 'phtml'

  • see: {render()}
  • access: public
Zend_Controller_Front $_frontController (line 57)

Front controller instance

  • access: protected
Zend_Controller_Action_HelperBroker $_helper = null (line 89)

Helper Broker to assist in routing help requests to the proper object

  • access: protected
array $_invokeArgs = array() (line 51)

Array of arguments provided to the constructor, minus the $_request.

  • access: protected
Zend_Controller_Request_Abstract $_request = null (line 63)

Zend_Controller_Request_Abstract object wrapping the request environment

  • access: protected
Zend_Controller_Response_Abstract $_response = null (line 69)

Zend_Controller_Response_Abstract object wrapping the response

  • access: protected
Methods
Constructor __construct (line 117)

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.

  • access: public
void __construct (Zend_Controller_Request_Abstract $request, Zend_Controller_Response_Abstract $response, [ $invokeArgs = array()])
dispatch (line 430)

Dispatch the requested action

  • access: public
void dispatch (string $action)
  • string $action: Method name of action
getFrontController (line 353)

Retrieve Front Controller

  • access: public
Zend_Controller_Front getFrontController ()
getHelper (line 320)

Get a helper by name

  • access: public
Zend_Controller_Action_Helper_Abstract getHelper (string $helperName)
  • string $helperName
getHelperCopy (line 331)

Get a clone of a helper by name

  • access: public
Zend_Controller_Action_Helper_Abstract getHelperCopy (string $helperName)
  • string $helperName
getInvokeArg (line 305)

Return a single invocation argument

  • access: public
mixed getInvokeArg (string $key)
  • string $key
getInvokeArgs (line 294)

Return the array of constructor arguments (minus the Request object)

  • access: public
array getInvokeArgs ()
getRequest (line 238)

Return the Request object

  • access: public
getResponse (line 260)

Return the Response object

  • access: public
getViewScript (line 215)

Construct view script path

Used by render() to determine the path to the view script.

  • throws: Zend_Controller_Exception with bad $action
  • access: public
string getViewScript ([string $action = null], [bool $noController = false])
  • 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
init (line 133)

Initialize object

Called from __construct() as final step of object instantiation.

  • access: public
void init ()
initView (line 153)

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:

  • script path = views/scripts/
  • helper path = views/helpers/
  • filter path = views/filters/

  • throws: Zend_Controller_Exception if base view directory does not exist
  • access: public
Zend_View_Interface initView ()
postDispatch (line 398)

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.

  • access: public
void postDispatch ()
preDispatch (line 381)

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.

  • access: public
void preDispatch ()
render (line 194)

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.

void render ([string|null $action = null], [string|null $name = null], [bool $noController = false])
  • 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
run (line 467)

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.

  • access: public
setFrontController (line 342)

Set the front controller instance

  • access: public
Zend_Controller_Action setFrontController (Zend_Controller_Front $front)
setRequest (line 249)

Set the Request object

  • access: public
setResponse (line 271)

Set the Response object

  • access: public
_forward (line 576)

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.

  • access: protected
void _forward (string $action, [string $controller = null], [string $module = null], [ $params = null])
  • string $action
  • string $controller
  • string $module
  • array $params
_getAllParams (line 544)

Return all parameters in the $_request as an associative array.

  • access: protected
array _getAllParams ()
_getParam (line 502)

Gets a parameter from the $_request. 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.

  • access: protected
mixed _getParam (string $paramName, [mixed $default = null])
  • string $paramName
  • mixed $default
_hasParam (line 533)

Determine whether a given parameter exists in the $_request.

  • access: protected
boolean _hasParam (string $paramName)
  • string $paramName
_redirect (line 606)

Redirect to another URL

Proxies to Zend_Controller_Action_Helper_Redirector::gotoUrl().

  • access: protected
void _redirect (string $url, [ $options = array()])
  • string $url
  • array $options: Options to be used when redirecting
_setInvokeArgs (line 283)

Set invocation arguments

  • access: protected
Zend_Controller_Action _setInvokeArgs ([ $args = array()])
  • array $args
_setParam (line 519)

Set a parameter in the $_request.

  • access: protected
Zend_Controller_Action _setParam (string $paramName, mixed $value)
  • string $paramName
  • mixed $value
__call (line 411)

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.

  • access: public
void __call (string $methodName, array $args)
  • string $methodName
  • array $args

Documentation generated on Sat, 05 May 2007 11:52:11 -0700 by phpDocumentor 1.3.2