API Documentation

Controller/Front.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: Front.php 20246 2010-01-12 21:36:08Z dasprid $
Classes
Zend_Controller_Front

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_Front

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
$_baseUrl
$_controllerDir
$_dispatcher
$_instance
$_invokeParams
$_moduleControllerDirectoryName
$_plugins
$_request
$_response
$_returnResponse
$_router
$_throwExceptions
Methods
__construct
__clone
getInstance
resetInstance
run
addControllerDirectory
setControllerDirectory
getControllerDirectory
removeControllerDirectory
addModuleDirectory
getModuleDirectory
setModuleControllerDirectoryName
getModuleControllerDirectoryName
setDefaultControllerName
getDefaultControllerName
setDefaultAction
getDefaultAction
setDefaultModule
getDefaultModule
setRequest
getRequest
setRouter
getRouter
setBaseUrl
getBaseUrl
setDispatcher
getDispatcher
setResponse
getResponse
setParam
setParams
getParam
getParams
clearParams
registerPlugin
unregisterPlugin
hasPlugin
getPlugin
getPlugins
throwExceptions
returnResponse
dispatch

Description

Properties

$_baseUrl

string $_baseUrl = 'null'

Base URL

Details

$_baseUrl
string
visibility
protected
default
null
final
false
static
false

$_controllerDir

string|array $_controllerDir = 'null'

Directory|ies where controllers are stored

Details

$_controllerDir
string|array
visibility
protected
default
null
final
false
static
false

$_dispatcher

Zend_Controller_Dispatcher_Interface $_dispatcher = 'null'

Instance of Zend_Controller_Dispatcher_Interface

Details

$_dispatcher
Zend_Controller_Dispatcher_Interface
visibility
protected
default
null
final
false
static
false

$_instance

Zend_Controller_Front $_instance = 'null'

Singleton instance

Marked only as protected to allow extension of the class. To extend, simply override {@link getInstance()}.

Details

$_instance
Zend_Controller_Front
visibility
protected
default
null
final
false
static
true

$_invokeParams

array $_invokeParams = 'array'

Array of invocation parameters to use when instantiating action controllers

Details

$_invokeParams
array
visibility
protected
default
array
final
false
static
false

$_moduleControllerDirectoryName

string $_moduleControllerDirectoryName = 'controllers'

Subdirectory within a module containing controllers; defaults to 'controllers'

Details

$_moduleControllerDirectoryName
string
visibility
protected
default
controllers
final
false
static
false

$_plugins

Zend_Controller_Plugin_Broker $_plugins = 'null'

Instance of Zend_Controller_Plugin_Broker

Details

$_plugins
Zend_Controller_Plugin_Broker
visibility
protected
default
null
final
false
static
false

$_request

Zend_Controller_Request_Abstract $_request = 'null'

Instance of Zend_Controller_Request_Abstract

Details

$_request
Zend_Controller_Request_Abstract
visibility
protected
default
null
final
false
static
false

$_response

Zend_Controller_Response_Abstract $_response = 'null'

Instance of Zend_Controller_Response_Abstract

Details

$_response
Zend_Controller_Response_Abstract
visibility
protected
default
null
final
false
static
false

$_returnResponse

boolean $_returnResponse = 'false'

Whether or not to return the response prior to rendering output while in {@link dispatch()}; default is to send headers and render output.

Details

$_returnResponse
boolean
visibility
protected
default
false
final
false
static
false

$_router

Zend_Controller_Router_Interface $_router = 'null'

Instance of Zend_Controller_Router_Interface

Details

$_router
Zend_Controller_Router_Interface
visibility
protected
default
null
final
false
static
false

$_throwExceptions

boolean $_throwExceptions = 'false'

Whether or not exceptions encountered in {@link dispatch()} should be thrown or trapped in the response object

Details

$_throwExceptions
boolean
visibility
protected
default
false
final
false
static
false

Methods

__clone

__clone( ) : void

Enforce singleton; disallow cloning

Details
visibility
private
final
false
static
false

__construct

__construct( ) : void

Constructor

Instantiate using {@link getInstance()}; front controller is a singleton object.

Instantiates the plugin broker.

Details
visibility
protected
final
false
static
false

addControllerDirectory

addControllerDirectory( string $directory, string $module = null ) : Zend_Controller_Front

Add a controller directory to the controller directory stack

If $args is presented and is a string, uses it for the array key mapping to the directory specified.

Arguments
$directory
string
$module
string
Optional argument; module with which to associate directory. If none provided, assumes 'default'
Details
visibility
public
final
false
static
false
throws
if directory not found or readable

addModuleDirectory

addModuleDirectory( string $path ) : Zend_Controller_Front

Specify a directory as containing modules

Iterates through the directory, adding any subdirectories as modules; the subdirectory within each module named after {@link $_moduleControllerDirectoryName} will be used as the controller directory path.

Arguments
$path
string
Details
visibility
public
final
false
static
false

clearParams

clearParams( null|string|array $name = null ) : Zend_Controller_Front

Clear the controller parameter stack

By default, clears all parameters. If a parameter name is given, clears only that parameter; if an array of parameter names is provided, clears each.

Arguments
$name
nullstringarray
single key or array of keys for params to clear
Details
visibility
public
final
false
static
false

dispatch

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

Dispatch an HTTP request to a controller/action.

Arguments
$request
Zend_Controller_Request_Abstractnull
$response
Zend_Controller_Response_Abstractnull
Output
void|Zend_Controller_Response_Abstract
Returns response object if returnResponse() is true
Details
visibility
public
final
false
static
false

getBaseUrl

getBaseUrl( ) : string

Retrieve the currently set base URL

Output
string
Details
visibility
public
final
false
static
false

getControllerDirectory

getControllerDirectory( string $name = null ) : array|string|null

Retrieve controller directory

Retrieves: - Array of all controller directories if no $name passed - String path if $name passed and exists as a key in controller directory array - null if $name passed but does not exist in controller directory keys

Arguments
$name
string
Default null
Output
array|string|null
Details
visibility
public
final
false
static
false

getDefaultAction

getDefaultAction( ) : string

Retrieve the default action (unformatted string)

Output
string
Details
visibility
public
final
false
static
false

getDefaultControllerName

getDefaultControllerName( ) : string

Retrieve the default controller (unformatted string)

Output
string
Details
visibility
public
final
false
static
false

getDefaultModule

getDefaultModule( ) : string

Retrieve the default module

Output
string
Details
visibility
public
final
false
static
false

getDispatcher

getDispatcher( ) : Zend_Controller_Dispatcher_Interface

Return the dispatcher object.

Details
visibility
public
final
false
static
false

getInstance

getInstance( ) : Zend_Controller_Front

Singleton instance

Details
visibility
public
final
false
static
true

getModuleControllerDirectoryName

getModuleControllerDirectoryName( ) : string

Return the directory name within a module containing controllers

Output
string
Details
visibility
public
final
false
static
false

getModuleDirectory

getModuleDirectory( string $module = null ) : string|null

Return the path to a module directory (but not the controllers directory within)

Arguments
$module
string
Output
string|null
Details
visibility
public
final
false
static
false

getParam

getParam( string $name ) : mixed

Retrieve a single parameter from the controller parameter stack

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

getParams

getParams( ) : array

Retrieve action controller instantiation parameters

Output
array
Details
visibility
public
final
false
static
false

getPlugin

getPlugin( string $class ) : false|Zend_Controller_Plugin_Abstract|array

Retrieve a plugin or plugins by class

Arguments
$class
string
Output
false|Zend_Controller_Plugin_Abstract|array
Details
visibility
public
final
false
static
false

getPlugins

getPlugins( ) : array

Retrieve all plugins

Output
array
Details
visibility
public
final
false
static
false

getRequest

getRequest( ) : null|Zend_Controller_Request_Abstract

Return the request object.

Details
visibility
public
final
false
static
false

getResponse

getResponse( ) : null|Zend_Controller_Response_Abstract

Return the response object.

Details
visibility
public
final
false
static
false

getRouter

getRouter( ) : Zend_Controller_Router_Interface

Return the router object.

Instantiates a Zend_Controller_Router_Rewrite object if no router currently set.

Details
visibility
public
final
false
static
false

hasPlugin

hasPlugin( string $class ) : bool

Is a particular plugin registered?

Arguments
$class
string
Output
bool
Details
visibility
public
final
false
static
false

registerPlugin

registerPlugin( Zend_Controller_Plugin_Abstract $plugin, int $stackIndex = null ) : Zend_Controller_Front

Register a plugin.

Arguments
$plugin
Zend_Controller_Plugin_Abstract
$stackIndex
int
Optional; stack index for plugin
Details
visibility
public
final
false
static
false

removeControllerDirectory

removeControllerDirectory( string $module ) : bool

Remove a controller directory by module name

Arguments
$module
string
Output
bool
Details
visibility
public
final
false
static
false

resetInstance

resetInstance( ) : void

Resets all object properties of the singleton instance

Primarily used for testing; could be used to chain front controllers.

Also resets action helper broker, clearing all registered helpers.

Details
visibility
public
final
false
static
false

returnResponse

returnResponse( boolean $flag = null ) : boolean|Zend_Controller_Front

Set whether {@link dispatch()} should return the response without first rendering output. By default, output is rendered and dispatch() returns nothing.

Arguments
$flag
boolean
Output
boolean|Zend_Controller_Front
Used as a setter, returns object; as a getter, returns boolean
Details
visibility
public
final
false
static
false

run

run( string|array $controllerDirectory ) : void

Convenience feature, calls setControllerDirectory()->setRouter()->dispatch()

In PHP 5.1.x, a call to a static method never populates $this -- so run() may actually be called after setting up your front controller.

Arguments
$controllerDirectory
stringarray
Path to Zend_Controller_Action controller classes or array of such paths
Details
visibility
public
final
false
static
true
throws
if called from an object instance

setBaseUrl

setBaseUrl( string $base = null ) : Zend_Controller_Front

Set the base URL used for requests

Use to set the base URL segment of the REQUEST_URI to use when determining PATH_INFO, etc. Examples: - /admin - /myapp - /subdir/index.php

Note that the URL should not include the full URI. Do not use: - http://example.com/admin - http://example.com/myapp - http://example.com/subdir/index.php

If a null value is passed, this can be used as well for autodiscovery (default).

Arguments
$base
string
Details
visibility
public
final
false
static
false
throws
for non-string $base

setControllerDirectory

setControllerDirectory( string|array $directory, string $module = null ) : Zend_Controller_Front

Set controller directory

Stores controller directory(ies) in dispatcher. May be an array of directories or a string containing a single directory.

Arguments
$directory
stringarray
Path to Zend_Controller_Action controller classes or array of such paths
$module
string
Optional module name to use with string $directory
Details
visibility
public
final
false
static
false

setDefaultAction

setDefaultAction( string $action ) : Zend_Controller_Front

Set the default action (unformatted string)

Arguments
$action
string
Details
visibility
public
final
false
static
false

setDefaultControllerName

setDefaultControllerName( string $controller ) : Zend_Controller_Front

Set the default controller (unformatted string)

Arguments
$controller
string
Details
visibility
public
final
false
static
false

setDefaultModule

setDefaultModule( string $module ) : Zend_Controller_Front

Set the default module name

Arguments
$module
string
Details
visibility
public
final
false
static
false

setDispatcher

setDispatcher( Zend_Controller_Dispatcher_Interface $dispatcher ) : Zend_Controller_Front

Set the dispatcher object. The dispatcher is responsible for taking a Zend_Controller_Dispatcher_Token object, instantiating the controller, and call the action method of the controller.

Arguments
$dispatcher
Zend_Controller_Dispatcher_Interface
Details
visibility
public
final
false
static
false

setModuleControllerDirectoryName

setModuleControllerDirectoryName( string $name = controllers ) : Zend_Controller_Front

Set the directory name within a module containing controllers

Arguments
$name
string
Details
visibility
public
final
false
static
false

setParam

setParam( string $name, mixed $value ) : Zend_Controller_Front

Add or modify a parameter to use when instantiating an action controller

Arguments
$name
string
$value
mixed
Details
visibility
public
final
false
static
false

setParams

setParams( array $params ) : Zend_Controller_Front

Set parameters to pass to action controller constructors

Arguments
$params
array
Details
visibility
public
final
false
static
false

setRequest

setRequest( string|Zend_Controller_Request_Abstract $request ) : Zend_Controller_Front

Set request class/object

Set the request object. The request holds the request environment.

If a class name is provided, it will instantiate it

Arguments
$request
stringZend_Controller_Request_Abstract
Details
visibility
public
final
false
static
false
throws
if invalid request class

setResponse

setResponse( string|Zend_Controller_Response_Abstract $response ) : Zend_Controller_Front

Set response class/object

Set the response object. The response is a container for action responses and headers. Usage is optional.

If a class name is provided, instantiates a response object.

Arguments
$response
stringZend_Controller_Response_Abstract
Details
visibility
public
final
false
static
false
throws
if invalid response class

setRouter

setRouter( string|Zend_Controller_Router_Interface $router ) : Zend_Controller_Front

Set router class/object

Set the router object. The router is responsible for mapping the request to a controller and action.

If a class name is provided, instantiates router with any parameters registered via {@link setParam()} or {@link setParams()}.

Arguments
$router
stringZend_Controller_Router_Interface
Details
visibility
public
final
false
static
false
throws
if invalid router class

throwExceptions

throwExceptions( boolean $flag = null ) : boolean|Zend_Controller_Front

Set the throwExceptions flag and retrieve current status

Set whether exceptions encounted in the dispatch loop should be thrown or caught and trapped in the response object.

Default behaviour is to trap them in the response object; call this method to have them thrown.

Passing no value will return the current value of the flag; passing a boolean true or false value will set the flag and return the current object instance.

Arguments
$flag
boolean
Defaults to null (return flag state)
Output
boolean|Zend_Controller_Front
Used as a setter, returns object; as a getter, returns boolean
Details
visibility
public
final
false
static
false

unregisterPlugin

unregisterPlugin( string|Zend_Controller_Plugin_Abstract $plugin ) : Zend_Controller_Front

Unregister a plugin.

Arguments
$plugin
stringZend_Controller_Plugin_Abstract
Plugin class or object to unregister
Details
visibility
public
final
false
static
false
Documentation was generated by DocBlox.