Controller/Dispatcher/Standard.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 [email protected] so we can send you a copy immediately.
- Category
- Zend
- Copyright
- Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
- License
- New BSD License
- Package
- Zend_Controller
- Subpackage
- Dispatcher
- Version
- $Id: Standard.php 24861 2012-06-01 23:40:13Z adamlundrigan $
\Zend_Controller_Dispatcher_Standard
- Parent(s)
- \Zend_Controller_Dispatcher_Abstract
- Category
- Zend
- Copyright
- Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
- License
- New BSD License
Properties


array $_controllerDirectory = array()
Controller directory(ies)
array()
Details- Type
- array


string $_defaultAction = 'index'
'index'
Details- Type
- string
- Inherited_from
- \Zend_Controller_Dispatcher_Abstract::$$_defaultAction


string $_defaultController = 'index'
Default controller
Inherited from: \Zend_Controller_Dispatcher_Abstract::$$_defaultController'index'
Details- Type
- string
- Inherited_from
- \Zend_Controller_Dispatcher_Abstract::$$_defaultController


string $_defaultModule = 'default'
'default'
Details- Type
- string
- Inherited_from
- \Zend_Controller_Dispatcher_Abstract::$$_defaultModule


\Zend_Controller_Front $_frontController =
Front Controller instance
Inherited from: \Zend_Controller_Dispatcher_Abstract::$$_frontController- Type
- \Zend_Controller_Front
- Inherited_from
- \Zend_Controller_Dispatcher_Abstract::$$_frontController


array $_invokeParams = array()
Array of invocation parameters to use when instantiating action controllers
Inherited from: \Zend_Controller_Dispatcher_Abstract::$$_invokeParamsarray()
Details- Type
- array
- Inherited_from
- \Zend_Controller_Dispatcher_Abstract::$$_invokeParams


string $_pathDelimiter = '_'
Path delimiter character
Inherited from: \Zend_Controller_Dispatcher_Abstract::$$_pathDelimiter'_'
Details- Type
- string
- Inherited_from
- \Zend_Controller_Dispatcher_Abstract::$$_pathDelimiter


\Zend_Controller_Response_Abstract|null $_response = null
Response object to pass to action controllers, if any
Inherited from: \Zend_Controller_Dispatcher_Abstract::$$_responsenull
Details- Type
- \Zend_Controller_Response_Abstract | null
- Inherited_from
- \Zend_Controller_Dispatcher_Abstract::$$_response


array $_wordDelimiter = array('-', '.')
Word delimiter characters
Inherited from: \Zend_Controller_Dispatcher_Abstract::$$_wordDelimiterarray('-', '.')
Details- Type
- array
- Inherited_from
- \Zend_Controller_Dispatcher_Abstract::$$_wordDelimiter
Methods


__construct(array $params = array()) : void
Constructor: Set current module to default value
Name | Type | Description |
---|---|---|
$params | array |


_formatName(string $unformatted, boolean $isAction = false) : string
Formats a string from a URI into a PHP-friendly name.
Inherited from: \Zend_Controller_Dispatcher_Abstract::_formatName()By default, replaces words separated by the word separator character(s) with camelCaps. If $isAction is false, it also preserves replaces words separated by the path separation character with an underscore, making the following word Title cased. All non-alphanumeric characters are removed.
Name | Type | Description |
---|---|---|
$unformatted | string | |
$isAction | boolean | Defaults to false |
Type | Description |
---|---|
string |


_verifyDelimiter(string | array $spec) : array
Verify a delimiter to use in controllers or actions. May be a single string or an array of strings.
Name | Type | Description |
---|---|---|
$spec | string | array |
Type | Description |
---|---|
array |
Exception | Description |
---|---|
\Zend_Controller_Dispatcher_Exception | with invalid delimiters |


addControllerDirectory(string $path, string $module = null) : \Zend_Controller_Dispatcher_Standard
Add a single path to the controller directory stack
Name | Type | Description |
---|---|---|
$path | string | |
$module | string |
Type | Description |
---|---|
\Zend_Controller_Dispatcher_Standard |


classToFilename(string $class) : string
Convert a class name to a filename
Name | Type | Description |
---|---|---|
$class | string |
Type | Description |
---|---|
string |


clearParams(null | string | array $name = null) : \Zend_Controller_Dispatcher_Abstract
Clear the controller parameter stack
Inherited from: \Zend_Controller_Dispatcher_Abstract::clearParams()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.
Name | Type | Description |
---|---|---|
$name | null | string | array | single key or array of keys for params to clear |
Type | Description |
---|---|
\Zend_Controller_Dispatcher_Abstract |


dispatch(\Zend_Controller_Request_Abstract $request, \Zend_Controller_Response_Abstract $response) : void
Dispatch to a controller/action
By default, if a controller is not dispatchable, dispatch() will throw an exception. If you wish to use the default controller instead, set the param 'useDefaultControllerAlways' via setParam().
Name | Type | Description |
---|---|---|
$request | \Zend_Controller_Request_Abstract | |
$response | \Zend_Controller_Response_Abstract |
Exception | Description |
---|---|
\Zend_Controller_Dispatcher_Exception |


formatActionName(string $unformatted) : string
Formats a string into an action name.
Inherited from: \Zend_Controller_Dispatcher_Abstract::formatActionName()This is used to take a raw action name, such as one that would be stored inside a Zend_Controller_Request_Abstract object, and reformat into a proper method name that would be found inside a class extending Zend_Controller_Action.
Name | Type | Description |
---|---|---|
$unformatted | string |
Type | Description |
---|---|
string |


formatClassName(string $moduleName, string $className) : string
Format action class name
Name | Type | Description |
---|---|---|
$moduleName | string | Name of the current module |
$className | string | Name of the action class |
Type | Description |
---|---|
string | Formatted class name |


formatControllerName(string $unformatted) : string
Formats a string into a controller name.
Inherited from: \Zend_Controller_Dispatcher_Abstract::formatControllerName()This is used to take a raw controller name, such as one stored inside a Zend_Controller_Request_Abstract object, and reformat it to a proper class name that a class extending Zend_Controller_Action would use.
Name | Type | Description |
---|---|---|
$unformatted | string |
Type | Description |
---|---|
string |


formatModuleName(string $unformatted) : string
Format the module name.
This is used to take a raw module name, such as one that would be packaged inside a request object, and reformat it to a proper directory/class name that a class extending Zend_Controller_Action would use.
Name | Type | Description |
---|---|---|
$unformatted | string |
Type | Description |
---|---|
string |


getActionMethod(\Zend_Controller_Request_Abstract $request) : string
Determine the action name
First attempt to retrieve from request; then from request params using action key; default to default action
Returns formatted action name
Name | Type | Description |
---|---|---|
$request | \Zend_Controller_Request_Abstract |
Type | Description |
---|---|
string |


getControllerClass(\Zend_Controller_Request_Abstract $request) : string | false
Get controller class name
Try request first; if not found, try pulling from request parameter; if still not found, fallback to default
Name | Type | Description |
---|---|---|
$request | \Zend_Controller_Request_Abstract |
Type | Description |
---|---|
string | false | Returns class name on success |


getControllerDirectory(string $module = null) : array | string
Return the currently set directories for Zend_Controller_Action class lookup
If a module is specified, returns just that directory.
Name | Type | Description |
---|---|---|
$module | string | Module name |
Type | Description |
---|---|
array | string | Returns array of all directories by default, single module directory if module argument provided |


getDefaultAction() : string
Retrieve the default action name (minus formatting)
Inherited from: \Zend_Controller_Dispatcher_Abstract::getDefaultAction()Type | Description |
---|---|
string |


getDefaultControllerClass(\Zend_Controller_Request_Abstract $request) : string
Retrieve default controller class
Determines whether the default controller to use lies within the requested module, or if the global default should be used.
By default, will only use the module default unless that controller does not exist; if this is the case, it falls back to the default controller in the default module.
Name | Type | Description |
---|---|---|
$request | \Zend_Controller_Request_Abstract |
Type | Description |
---|---|
string |


getDefaultControllerName() : string
Retrieve the default controller name (minus formatting)
Inherited from: \Zend_Controller_Dispatcher_Abstract::getDefaultControllerName()Type | Description |
---|---|
string |


getDefaultModule() : string
Retrieve the default module
Inherited from: \Zend_Controller_Dispatcher_Abstract::getDefaultModule()Type | Description |
---|---|
string |


getDispatchDirectory() : string
Return the value of the currently selected dispatch directory (as set by {@link getController()})
Type | Description |
---|---|
string |


getFrontController() : \Zend_Controller_Front
Retrieve front controller instance
Inherited from: \Zend_Controller_Dispatcher_Abstract::getFrontController()Type | Description |
---|---|
\Zend_Controller_Front |


getParam(string $name) : mixed
Retrieve a single parameter from the controller parameter stack
Inherited from: \Zend_Controller_Dispatcher_Abstract::getParam()Name | Type | Description |
---|---|---|
$name | string |
Type | Description |
---|---|
mixed |


getParams() : array
Retrieve action controller instantiation parameters
Inherited from: \Zend_Controller_Dispatcher_Abstract::getParams()Type | Description |
---|---|
array |


getPathDelimiter() : array
Retrieve the path delimiter character(s) used in controller names
Inherited from: \Zend_Controller_Dispatcher_Abstract::getPathDelimiter()Type | Description |
---|---|
array |


getResponse() : \Zend_Controller_Response_Abstract | null
Return the registered response object
Inherited from: \Zend_Controller_Dispatcher_Abstract::getResponse()Type | Description |
---|---|
\Zend_Controller_Response_Abstract | null |


getWordDelimiter() : array
Retrieve the word delimiter character(s) used in controller or action names
Inherited from: \Zend_Controller_Dispatcher_Abstract::getWordDelimiter()Type | Description |
---|---|
array |


isDispatchable( $request) : boolean
Returns TRUE if the Zend_Controller_Request_Abstract object can be dispatched to a controller.
Use this method wisely. By default, the dispatcher will fall back to the default controller (either in the module specified or the global default) if a given controller does not exist. This method returning false does not necessarily indicate the dispatcher will not still dispatch the call.
Name | Type | Description |
---|---|---|
$request |
Type | Description |
---|---|
boolean |


isValidModule(string $module) : bool
Determine if a given module is valid
Name | Type | Description |
---|---|---|
$module | string |
Type | Description |
---|---|
bool |


loadClass(string $className) : string
Load a controller class
Attempts to load the controller class file from getControllerDirectory(). If the controller belongs to a module, looks for the module prefix to the controller class.
Name | Type | Description |
---|---|---|
$className | string |
Type | Description |
---|---|
string | Class name loaded |
Exception | Description |
---|---|
\Zend_Controller_Dispatcher_Exception | if class not loaded |


removeControllerDirectory(string $module) : bool
Remove a controller directory by module name
Name | Type | Description |
---|---|---|
$module | string |
Type | Description |
---|---|
bool |


setControllerDirectory(array | string $directory, $module = null) : \Zend_Controller_Dispatcher_Standard
Set controller directory
Specify a string or an array; if an array is specified, all paths will be added.
Name | Type | Description |
---|---|---|
$directory | array | string | |
$module |
Type | Description |
---|---|
\Zend_Controller_Dispatcher_Standard |


setDefaultAction(string $action) : \Zend_Controller_Dispatcher_Abstract
Set the default action (minus any formatting)
Inherited from: \Zend_Controller_Dispatcher_Abstract::setDefaultAction()Name | Type | Description |
---|---|---|
$action | string |
Type | Description |
---|---|
\Zend_Controller_Dispatcher_Abstract |


setDefaultControllerName(string $controller) : \Zend_Controller_Dispatcher_Abstract
Set the default controller (minus any formatting)
Inherited from: \Zend_Controller_Dispatcher_Abstract::setDefaultControllerName()Name | Type | Description |
---|---|---|
$controller | string |
Type | Description |
---|---|
\Zend_Controller_Dispatcher_Abstract |


setDefaultModule(string $module) : \Zend_Controller_Dispatcher_Abstract
Set the default module
Inherited from: \Zend_Controller_Dispatcher_Abstract::setDefaultModule()Name | Type | Description |
---|---|---|
$module | string |
Type | Description |
---|---|
\Zend_Controller_Dispatcher_Abstract |


setFrontController(\Zend_Controller_Front $controller) : \Zend_Controller_Dispatcher_Abstract
Set front controller instance
Inherited from: \Zend_Controller_Dispatcher_Abstract::setFrontController()Name | Type | Description |
---|---|---|
$controller | \Zend_Controller_Front |
Type | Description |
---|---|
\Zend_Controller_Dispatcher_Abstract |


setParam(string $name, mixed $value) : \Zend_Controller_Dispatcher_Abstract
Add or modify a parameter to use when instantiating an action controller
Inherited from: \Zend_Controller_Dispatcher_Abstract::setParam()Name | Type | Description |
---|---|---|
$name | string | |
$value | mixed |
Type | Description |
---|---|
\Zend_Controller_Dispatcher_Abstract |


setParams(array $params) : \Zend_Controller_Dispatcher_Abstract
Set parameters to pass to action controller constructors
Inherited from: \Zend_Controller_Dispatcher_Abstract::setParams()Name | Type | Description |
---|---|---|
$params | array |
Type | Description |
---|---|
\Zend_Controller_Dispatcher_Abstract |


setPathDelimiter(string $spec) : \Zend_Controller_Dispatcher_Abstract
Set path delimiter
Inherited from: \Zend_Controller_Dispatcher_Abstract::setPathDelimiter()Set the path delimiter to use in controllers. May be a single string or an array of strings.
Name | Type | Description |
---|---|---|
$spec | string |
Type | Description |
---|---|
\Zend_Controller_Dispatcher_Abstract |


setResponse(\Zend_Controller_Response_Abstract | null $response = null) : \Zend_Controller_Dispatcher_Abstract
Set response object to pass to action controllers
Inherited from: \Zend_Controller_Dispatcher_Abstract::setResponse()Name | Type | Description |
---|---|---|
$response | \Zend_Controller_Response_Abstract | null |
Type | Description |
---|---|
\Zend_Controller_Dispatcher_Abstract |


setWordDelimiter(string | array $spec) : \Zend_Controller_Dispatcher_Abstract
Set word delimiter
Inherited from: \Zend_Controller_Dispatcher_Abstract::setWordDelimiter()Set the word delimiter to use in controllers and actions. May be a single string or an array of strings.
Name | Type | Description |
---|---|---|
$spec | string | array |
Type | Description |
---|---|
\Zend_Controller_Dispatcher_Abstract |