API Documentation

Controller/Action.php

Includes Classes 
category
Zend
copyright
Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
license
http://framework.zend.com/license/new-bsd New BSD License
package
Zend_Controller
version
$Id: Action.php 22793 2010-08-05 18:32:52Z matthew $
Classes
Zend_Controller_Action

Description

Zend Framework

LICENSE

This source file is subject to the new BSD license that is bundled with this package in the file LICENSE.txt. It is also available through the world-wide-web at this URL: http://framework.zend.com/license/new-bsd If you did not receive a copy of the license and are unable to obtain it through the world-wide-web, please send an email to license@zend.com so we can send you a copy immediately.

Zend_Controller_Action

Implements
Zend_Controller_Action_Interface
category
Zend
copyright
Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
license
http://framework.zend.com/license/new-bsd New BSD License
package
Zend_Controller
Properties
$_classMethods
$_delimiters
$_invokeArgs
$_frontController
$_request
$_response
$viewSuffix
$view
$_helper
Methods
__construct
init
initView
render
renderScript
getViewScript
getRequest
setRequest
getResponse
setResponse
_setInvokeArgs
getInvokeArgs
getInvokeArg
getHelper
getHelperCopy
setFrontController
getFrontController
preDispatch
postDispatch
__call
dispatch
run
_getParam
_setParam
_hasParam
_getAllParams
_forward
_redirect

Description

Properties

$_classMethods

array $_classMethods = ''

Details

$_classMethods
array
of existing class methods
visibility
protected
default
final
false
static
false

$_delimiters

array $_delimiters = ''

Word delimiters (used for normalizing view script paths)

Details

$_delimiters
array
visibility
protected
default
final
false
static
false

$_frontController

Zend_Controller_Front $_frontController = ''

Front controller instance

Details

$_frontController
Zend_Controller_Front
visibility
protected
default
final
false
static
false

$_helper

Zend_Controller_Action_HelperBroker $_helper = 'null'

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

Details

$_helper
Zend_Controller_Action_HelperBroker
visibility
protected
default
null
final
false
static
false

$_invokeArgs

array $_invokeArgs = 'array'

Array of arguments provided to the constructor, minus the {@link $_request Request object}.

Details

$_invokeArgs
array
visibility
protected
default
array
final
false
static
false

$_request

Zend_Controller_Request_Abstract $_request = 'null'

Zend_Controller_Request_Abstract object wrapping the request environment

Details

$_request
Zend_Controller_Request_Abstract
visibility
protected
default
null
final
false
static
false

$_response

Zend_Controller_Response_Abstract $_response = 'null'

Zend_Controller_Response_Abstract object wrapping the response

Details

$_response
Zend_Controller_Response_Abstract
visibility
protected
default
null
final
false
static
false

$view

Zend_View_Interface $view = ''

View object

Details

$view
Zend_View_Interface
visibility
public
default
final
false
static
false

$viewSuffix

string $viewSuffix = 'phtml'

View script suffix; defaults to 'phtml'

Details

$viewSuffix
string
visibility
public
default
phtml
final
false
static
false
see
{render()}

Methods

__call

__call( string $methodName, array $args ) : void

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.

Arguments
$methodName
string
$args
array
Details
visibility
public
final
false
static
false
throws

__construct

__construct( Zend_Controller_Request_Abstract $request, Zend_Controller_Response_Abstract $response, array $invokeArgs = array ) : void

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 {@link getRequest()}, {@link getResponse()}, and {@link 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 {@link $_helper helper broker} is initialized.

Finally, {@link init()} is called as the final action of instantiation, and may be safely overridden to perform initialization tasks; as a general rule, override {@link init()} instead of the constructor to customize an action controller's instantiation.

Arguments
$request
Zend_Controller_Request_Abstract
$response
Zend_Controller_Response_Abstract
$invokeArgs
array
Any additional invocation arguments
Details
visibility
public
final
false
static
false

_forward

_forward( string $action, string $controller = null, string $module = null, array $params = null ) : void

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.

Arguments
$action
string
$controller
string
$module
string
$params
array
Details
visibility
protected
final
true
static
false

_getAllParams

_getAllParams( ) : array

Return all parameters in the {@link $_request Request object} as an associative array.

Output
array
Details
visibility
protected
final
false
static
false

_getParam

_getParam( string $paramName, mixed $default = null ) : mixed

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

Arguments
$paramName
string
$default
mixed
Output
mixed
Details
visibility
protected
final
false
static
false

_hasParam

_hasParam( string $paramName ) : boolean

Determine whether a given parameter exists in the {@link $_request Request object}.

Arguments
$paramName
string
Output
boolean
Details
visibility
protected
final
false
static
false

_redirect

_redirect( string $url, array $options = array ) : void

Redirect to another URL

Proxies to {@link Zend_Controller_Action_Helper_Redirector::gotoUrl()}.

Arguments
$url
string
$options
array
Options to be used when redirecting
Details
visibility
protected
final
false
static
false

_setInvokeArgs

_setInvokeArgs( array $args = array ) : Zend_Controller_Action

Set invocation arguments

Arguments
$args
array
Details
visibility
protected
final
false
static
false

_setParam

_setParam( string $paramName, mixed $value ) : Zend_Controller_Action

Set a parameter in the {@link $_request Request object}.

Arguments
$paramName
string
$value
mixed
Details
visibility
protected
final
false
static
false

dispatch

dispatch( string $action ) : void

Dispatch the requested action

Arguments
$action
string
Method name of action
Details
visibility
public
final
false
static
false

getFrontController

getFrontController( ) : Zend_Controller_Front

Retrieve Front Controller

Details
visibility
public
final
false
static
false

getHelper

getHelper( string $helperName ) : Zend_Controller_Action_Helper_Abstract

Get a helper by name

Arguments
$helperName
string
Details
visibility
public
final
false
static
false

getHelperCopy

getHelperCopy( string $helperName ) : Zend_Controller_Action_Helper_Abstract

Get a clone of a helper by name

Arguments
$helperName
string
Details
visibility
public
final
false
static
false

getInvokeArg

getInvokeArg( string $key ) : mixed

Return a single invocation argument

Arguments
$key
string
Output
mixed
Details
visibility
public
final
false
static
false

getInvokeArgs

getInvokeArgs( ) : array

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

Output
array
Details
visibility
public
final
false
static
false

getRequest

getRequest( ) : Zend_Controller_Request_Abstract

Return the Request object

Details
visibility
public
final
false
static
false

getResponse

getResponse( ) : Zend_Controller_Response_Abstract

Return the Response object

Details
visibility
public
final
false
static
false

getViewScript

getViewScript( string $action = null, bool $noController = null ) : string

Construct view script path

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

Arguments
$action
string
Defaults to action registered in request object
$noController
bool
Defaults to false; i.e. use controller name as subdir in which to search for view script
Output
string
Details
visibility
public
final
false
static
false
throws
with bad $action

init

init( ) : void

Initialize object

Called from {@link __construct()} as final step of object instantiation.

Details
visibility
public
final
false
static
false

initView

initView( ) : Zend_View_Interface

Initialize View object

Initializes {@link $view} if not otherwise a Zend_View_Interface.

If {@link $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/

Details
visibility
public
final
false
static
false
throws
if base view directory does not exist

postDispatch

postDispatch( ) : void

Post-dispatch routines

Called after action method execution. If using class with {@link Zend_Controller_Front}, it may modify the {@link $_request 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.

Details
visibility
public
final
false
static
false

preDispatch

preDispatch( ) : void

Pre-dispatch routines

Called before action method. If using class with {@link Zend_Controller_Front}, it may modify the {@link $_request Request object} and reset its dispatched flag in order to skip processing the current action.

Details
visibility
public
final
false
static
false

render

render( string|null $action = null, string|null $name = null, bool $noController = false ) : void

Render a view

Renders a view. By default, views are found in the view script path as /.phtml. You may change the script suffix by resetting {@link $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.

Arguments
$action
stringnull
Defaults to action registered in request object
$name
stringnull
Response object named path segment to use; defaults to null
$noController
bool
Defaults to false; i.e. use controller name as subdir in which to search for view script
Details
visibility
public
final
false
static
false
see
Zend_Controller_Response_Abstract::appendBody()

renderScript

renderScript( string $script, string $name = null ) : void

Render a given view script

Similar to {@link render()}, this method renders a view script. Unlike render(), however, it does not autodetermine the view script via {@link 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.

Arguments
$script
string
$name
string
Details
visibility
public
final
false
static
false

run

run( null|Zend_Controller_Request_Abstract $request = null, null|Zend_Controller_Response_Abstract $response = null ) : Zend_Controller_Response_Abstract

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.

{@link preDispatch()} is called prior to the action, {@link postDispatch()} is called following it.

Arguments
$request
nullZend_Controller_Request_Abstract
Optional request object to use
$response
nullZend_Controller_Response_Abstract
Optional response object to use
Details
visibility
public
final
false
static
false

setFrontController

setFrontController( Zend_Controller_Front $front ) : Zend_Controller_Action

Set the front controller instance

Arguments
$front
Zend_Controller_Front
Details
visibility
public
final
false
static
false

setRequest

setRequest( Zend_Controller_Request_Abstract $request ) : Zend_Controller_Action

Set the Request object

Arguments
$request
Zend_Controller_Request_Abstract
Details
visibility
public
final
false
static
false

setResponse

setResponse( Zend_Controller_Response_Abstract $response ) : Zend_Controller_Action

Set the Response object

Arguments
$response
Zend_Controller_Response_Abstract
Details
visibility
public
final
false
static
false
Documentation was generated by DocBlox.