Controller/Front.php
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.
- Category
- Zend
- Copyright
- Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
- License
- New BSD License
- Package
- Zend_Controller
- Version
- $Id$
Package: Zend_Controller- Category
- Zend
- Copyright
- Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
- License
- New BSD License
Properties
string|array $_controllerDir = null
Directory|ies where controllers are stored
Default valuenull
Details- Type
- string | array
array $_invokeParams = array()
Array of invocation parameters to use when instantiating action
controllers
Default valuearray()
Details- Type
- array
string $_moduleControllerDirectoryName = 'controllers'
Subdirectory within a module containing controllers; defaults to 'controllers'
Default value'controllers'
Details- Type
- string
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.
Default valuefalse
Details- Type
- boolean
boolean $_throwExceptions = false
Whether or not exceptions encountered in {@link dispatch()} should be
thrown or trapped in the response object
Default valuefalse
Details- Type
- boolean
Methods
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.
ParametersName | Type | Description |
---|
$directory | string | |
---|
$module | string | Optional argument; module with which to associate directory. If none provided, assumes 'default' |
---|
ReturnsThrowsaddModuleDirectory(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.
ParametersName | Type | Description |
---|
$path | string | |
---|
ReturnsclearParams( $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.
ParametersReturnsgetControllerDirectory(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
ParametersName | Type | Description |
---|
$name | string | Default null |
---|
ReturnsType | Description |
---|
array | string | null | |
getModuleDirectory(string $module = null) : string | null
Return the path to a module directory (but not the controllers directory within)
ParametersName | Type | Description |
---|
$module | string | |
---|
ReturnsType | Description |
---|
string | null | |
getParam(string $name) : mixed
Retrieve a single parameter from the controller parameter stack
ParametersName | Type | Description |
---|
$name | string | |
---|
Returns getPlugin(string $class) : false | \Zend_Controller_Plugin_Abstract | array
Retrieve a plugin or plugins by class
ParametersName | Type | Description |
---|
$class | string | |
---|
Returns hasPlugin(string $class) : bool
Is a particular plugin registered?
ParametersName | Type | Description |
---|
$class | string | |
---|
Returns removeControllerDirectory(string $module) : bool
Remove a controller directory by module name
ParametersName | Type | Description |
---|
$module | string | |
---|
Returns 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.
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.
ParametersName | Type | Description |
---|
$flag | boolean | |
---|
Returns run(string | array $controllerDirectory) : void
staticConvenience 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.
ParametersName | Type | Description |
---|
$controllerDirectory | string | array | Path to Zend_Controller_Action
controller classes or array of such paths |
---|
ThrowssetBaseUrl(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).
ParametersName | Type | Description |
---|
$base | string | |
---|
ReturnsThrowssetControllerDirectory(string | array $directory, string $module = null) : \Zend_Controller_Front
Stores controller directory(ies) in dispatcher. May be an array of
directories or a string containing a single directory.
ParametersName | Type | Description |
---|
$directory | string | array | Path to Zend_Controller_Action controller
classes or array of such paths |
---|
$module | string | Optional module name to use with string $directory |
---|
ReturnssetDefaultAction(string $action) : \Zend_Controller_Front
Set the default action (unformatted string)
ParametersName | Type | Description |
---|
$action | string | |
---|
Returns setDefaultControllerName(string $controller) : \Zend_Controller_Front
Set the default controller (unformatted string)
ParametersName | Type | Description |
---|
$controller | string | |
---|
Returns setDefaultModule(string $module) : \Zend_Controller_Front
Set the default module name
ParametersName | Type | Description |
---|
$module | string | |
---|
Returns setModuleControllerDirectoryName(string $name = 'controllers') : \Zend_Controller_Front
Set the directory name within a module containing controllers
ParametersName | Type | Description |
---|
$name | string | |
---|
Returns setParam(string $name, mixed $value) : \Zend_Controller_Front
Add or modify a parameter to use when instantiating an action controller
ParametersName | Type | Description |
---|
$name | string | |
---|
$value | mixed | |
---|
Returns setParams(array $params) : \Zend_Controller_Front
Set parameters to pass to action controller constructors
ParametersName | Type | Description |
---|
$params | array | |
---|
Returns 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.
ParametersReturnsThrowsthrowExceptions(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.
ParametersName | Type | Description |
---|
$flag | boolean | Defaults to null (return flag state) |
---|
Returns