Zend Framework  1.12
Public Member Functions | Protected Attributes | List of all members
Zend_Controller_Dispatcher_Standard Class Reference

Public Member Functions

 __construct (array $params=array())
 Constructor: Set current module to default value.
 
 addControllerDirectory ($path, $module=null)
 Add a single path to the controller directory stack.
 
 setControllerDirectory ($directory, $module=null)
 Set controller directory.
 
 getControllerDirectory ($module=null)
 Return the currently set directories for Zend_Controller_Action class lookup.
 
 removeControllerDirectory ($module)
 Remove a controller directory by module name.
 
 formatModuleName ($unformatted)
 Format the module name.
 
 formatClassName ($moduleName, $className)
 Format action class name.
 
 classToFilename ($class)
 Convert a class name to a filename.
 
 isDispatchable (Zend_Controller_Request_Abstract $request)
 Returns TRUE if the Zend_Controller_Request_Abstract object can be dispatched to a controller.
 
 dispatch (Zend_Controller_Request_Abstract $request, Zend_Controller_Response_Abstract $response)
 Dispatch to a controller/action.
 
 loadClass ($className)
 Load a controller class.
 
 getControllerClass (Zend_Controller_Request_Abstract $request)
 Get controller class name.
 
 isValidModule ($module)
 Determine if a given module is valid.
 
 getDefaultControllerClass (Zend_Controller_Request_Abstract $request)
 Retrieve default controller class.
 
 getDispatchDirectory ()
 Return the value of the currently selected dispatch directory (as set by getController())
 
 getActionMethod (Zend_Controller_Request_Abstract $request)
 Determine the action name.
 
- Public Member Functions inherited from Zend_Controller_Dispatcher_Abstract
 __construct (array $params=array())
 Constructor.
 
 formatControllerName ($unformatted)
 Formats a string into a controller name.
 
 formatActionName ($unformatted)
 Formats a string into an action name.
 
 _verifyDelimiter ($spec)
 Verify delimiter.
 
 getWordDelimiter ()
 Retrieve the word delimiter character(s) used in controller or action names.
 
 setWordDelimiter ($spec)
 Set word delimiter.
 
 getPathDelimiter ()
 Retrieve the path delimiter character(s) used in controller names.
 
 setPathDelimiter ($spec)
 Set path delimiter.
 
 getFrontController ()
 Retrieve front controller instance.
 
 setFrontController (Zend_Controller_Front $controller)
 Set front controller instance.
 
 setParam ($name, $value)
 Add or modify a parameter to use when instantiating an action controller.
 
 setParams (array $params)
 Set parameters to pass to action controller constructors.
 
 getParam ($name)
 Retrieve a single parameter from the controller parameter stack.
 
 getParams ()
 Retrieve action controller instantiation parameters.
 
 clearParams ($name=null)
 Clear the controller parameter stack.
 
 setResponse (Zend_Controller_Response_Abstract $response=null)
 Set response object to pass to action controllers.
 
 getResponse ()
 Return the registered response object.
 
 setDefaultControllerName ($controller)
 Set the default controller (minus any formatting)
 
 getDefaultControllerName ()
 Retrieve the default controller name (minus formatting)
 
 setDefaultAction ($action)
 Set the default action (minus any formatting)
 
 getDefaultAction ()
 Retrieve the default action name (minus formatting)
 
 setDefaultModule ($module)
 Set the default module.
 
 getDefaultModule ()
 Retrieve the default module.
 
- Public Member Functions inherited from Zend_Controller_Dispatcher_Interface
 setControllerDirectory ($path)
 Set the directory where controller files are stored.
 
 getControllerDirectory ()
 Return the currently set directory(ies) for controller file lookup.
 

Protected Attributes

 $_curDirectory
 
 $_curModule
 
 $_controllerDirectory = array()
 
- Protected Attributes inherited from Zend_Controller_Dispatcher_Abstract
 $_defaultAction = 'index'
 
 $_defaultController = 'index'
 
 $_defaultModule = 'default'
 
 $_frontController
 
 $_invokeParams = array()
 
 $_pathDelimiter = '_'
 
 $_response = null
 
 $_wordDelimiter = array('-', '.')
 

Additional Inherited Members

- Protected Member Functions inherited from Zend_Controller_Dispatcher_Abstract
 _formatName ($unformatted, $isAction=false)
 Formats a string from a URI into a PHP-friendly name.
 

Constructor & Destructor Documentation

__construct ( array  $params = array())

Constructor: Set current module to default value.

Parameters
array$params
Returns
void

Member Function Documentation

addControllerDirectory (   $path,
  $module = null 
)

Add a single path to the controller directory stack.

Parameters
string$path
string$module
Returns
Zend_Controller_Dispatcher_Standard

Implements Zend_Controller_Dispatcher_Interface.

classToFilename (   $class)

Convert a class name to a filename.

Parameters
string$class
Returns
string

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().

Parameters
Zend_Controller_Request_Abstract$request
Zend_Controller_Response_Abstract$response
Returns
void
Exceptions
Zend_Controller_Dispatcher_Exception

Get controller class

If we're in a module or prefixDefaultModule is on, we must add the module name prefix to the contents of $className, as getControllerClass does not do that automatically. We must keep a separate variable because modules are not strictly PSR-0: We need the no-module-prefix class name to do the class->file mapping, but the full class name to insantiate the controller

Load the controller class file

Instantiate controller with request, response, and invocation arguments; throw exception if it's not an action controller

Retrieve the action name

Dispatch the method call

Implements Zend_Controller_Dispatcher_Interface.

formatClassName (   $moduleName,
  $className 
)

Format action class name.

Parameters
string$moduleNameName of the current module
string$classNameName of the action class
Returns
string Formatted class name
formatModuleName (   $unformatted)

Format the module name.

Parameters
string$unformatted
Returns
string

Implements Zend_Controller_Dispatcher_Interface.

getActionMethod ( Zend_Controller_Request_Abstract  $request)

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

Parameters
Zend_Controller_Request_Abstract$request
Returns
string
getControllerClass ( Zend_Controller_Request_Abstract  $request)

Get controller class name.

Try request first; if not found, try pulling from request parameter; if still not found, fallback to default

Parameters
Zend_Controller_Request_Abstract$request
Returns
string|false Returns class name on success
getControllerDirectory (   $module = null)

Return the currently set directories for Zend_Controller_Action class lookup.

If a module is specified, returns just that directory.

Parameters
string$moduleModule name
Returns
array|string Returns array of all directories by default, single module directory if module argument provided
getDefaultControllerClass ( Zend_Controller_Request_Abstract  $request)

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.

Parameters
Zend_Controller_Request_Abstract$request
Returns
string
getDispatchDirectory ( )

Return the value of the currently selected dispatch directory (as set by getController())

Returns
string
isDispatchable ( Zend_Controller_Request_Abstract  $request)

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.

Parameters
Zend_Controller_Request_Abstract$action
Returns
boolean

Implements Zend_Controller_Dispatcher_Interface.

isValidModule (   $module)

Determine if a given module is valid.

Parameters
string$module
Returns
bool

Implements Zend_Controller_Dispatcher_Interface.

loadClass (   $className)

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.

Parameters
string$className
Returns
string Class name loaded
Exceptions
Zend_Controller_Dispatcher_Exceptionif class not loaded
removeControllerDirectory (   $module)

Remove a controller directory by module name.

Parameters
string$module
Returns
bool
setControllerDirectory (   $directory,
  $module = null 
)

Set controller directory.

Parameters
array | string$directory
Returns
Zend_Controller_Dispatcher_Standard

Member Data Documentation

$_controllerDirectory = array()
protected
$_curDirectory
protected
$_curModule
protected