Interface.php 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. <?php
  2. /**
  3. * Zend Framework
  4. *
  5. * LICENSE
  6. *
  7. * This source file is subject to the new BSD license that is bundled
  8. * with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://framework.zend.com/license/new-bsd
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@zend.com so we can send you a copy immediately.
  14. *
  15. * @category Zend
  16. * @package Zend_Controller
  17. * @subpackage Dispatcher
  18. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. * @version $Id$
  21. */
  22. /**
  23. * Zend_Controller_Request_Abstract
  24. */
  25. require_once 'Zend/Controller/Request/Abstract.php';
  26. /**
  27. * Zend_Controller_Response_Abstract
  28. */
  29. require_once 'Zend/Controller/Response/Abstract.php';
  30. /**
  31. * @package Zend_Controller
  32. * @subpackage Dispatcher
  33. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  34. * @license http://framework.zend.com/license/new-bsd New BSD License
  35. */
  36. interface Zend_Controller_Dispatcher_Interface
  37. {
  38. /**
  39. * Formats a string into a controller name. This is used to take a raw
  40. * controller name, such as one that would be packaged inside a request
  41. * object, and reformat it to a proper class name that a class extending
  42. * Zend_Controller_Action would use.
  43. *
  44. * @param string $unformatted
  45. * @return string
  46. */
  47. public function formatControllerName($unformatted);
  48. /**
  49. * Formats a string into a module name. This is used to take a raw
  50. * module name, such as one that would be packaged inside a request
  51. * object, and reformat it to a proper directory/class name that a class extending
  52. * Zend_Controller_Action would use.
  53. *
  54. * @param string $unformatted
  55. * @return string
  56. */
  57. public function formatModuleName($unformatted);
  58. /**
  59. * Formats a string into an action name. This is used to take a raw
  60. * action name, such as one that would be packaged inside a request
  61. * object, and reformat into a proper method name that would be found
  62. * inside a class extending Zend_Controller_Action.
  63. *
  64. * @param string $unformatted
  65. * @return string
  66. */
  67. public function formatActionName($unformatted);
  68. /**
  69. * Returns TRUE if an action can be dispatched, or FALSE otherwise.
  70. *
  71. * @param Zend_Controller_Request_Abstract $request
  72. * @return boolean
  73. */
  74. public function isDispatchable(Zend_Controller_Request_Abstract $request);
  75. /**
  76. * Add or modify a parameter with which to instantiate an Action Controller
  77. *
  78. * @param string $name
  79. * @param mixed $value
  80. * @return Zend_Controller_Dispatcher_Interface
  81. */
  82. public function setParam($name, $value);
  83. /**
  84. * Set an array of a parameters to pass to the Action Controller constructor
  85. *
  86. * @param array $params
  87. * @return Zend_Controller_Dispatcher_Interface
  88. */
  89. public function setParams(array $params);
  90. /**
  91. * Retrieve a single parameter from the controller parameter stack
  92. *
  93. * @param string $name
  94. * @return mixed
  95. */
  96. public function getParam($name);
  97. /**
  98. * Retrieve the parameters to pass to the Action Controller constructor
  99. *
  100. * @return array
  101. */
  102. public function getParams();
  103. /**
  104. * Clear the controller parameter stack
  105. *
  106. * By default, clears all parameters. If a parameter name is given, clears
  107. * only that parameter; if an array of parameter names is provided, clears
  108. * each.
  109. *
  110. * @param null|string|array single key or array of keys for params to clear
  111. * @return Zend_Controller_Dispatcher_Interface
  112. */
  113. public function clearParams($name = null);
  114. /**
  115. * Set the response object to use, if any
  116. *
  117. * @param Zend_Controller_Response_Abstract|null $response
  118. * @return void
  119. */
  120. public function setResponse(Zend_Controller_Response_Abstract $response = null);
  121. /**
  122. * Retrieve the response object, if any
  123. *
  124. * @return Zend_Controller_Response_Abstract|null
  125. */
  126. public function getResponse();
  127. /**
  128. * Add a controller directory to the controller directory stack
  129. *
  130. * @param string $path
  131. * @param string $args
  132. * @return Zend_Controller_Dispatcher_Interface
  133. */
  134. public function addControllerDirectory($path, $args = null);
  135. /**
  136. * Set the directory where controller files are stored
  137. *
  138. * Specify a string or an array; if an array is specified, all paths will be
  139. * added.
  140. *
  141. * @param string|array $dir
  142. * @return Zend_Controller_Dispatcher_Interface
  143. */
  144. public function setControllerDirectory($path);
  145. /**
  146. * Return the currently set directory(ies) for controller file lookup
  147. *
  148. * @return array
  149. */
  150. public function getControllerDirectory();
  151. /**
  152. * Dispatches a request object to a controller/action. If the action
  153. * requests a forward to another action, a new request will be returned.
  154. *
  155. * @param Zend_Controller_Request_Abstract $request
  156. * @param Zend_Controller_Response_Abstract $response
  157. * @return void
  158. */
  159. public function dispatch(Zend_Controller_Request_Abstract $request, Zend_Controller_Response_Abstract $response);
  160. /**
  161. * Whether or not a given module is valid
  162. *
  163. * @param string $module
  164. * @return boolean
  165. */
  166. public function isValidModule($module);
  167. /**
  168. * Retrieve the default module name
  169. *
  170. * @return string
  171. */
  172. public function getDefaultModule();
  173. /**
  174. * Retrieve the default controller name
  175. *
  176. * @return string
  177. */
  178. public function getDefaultControllerName();
  179. /**
  180. * Retrieve the default action
  181. *
  182. * @return string
  183. */
  184. public function getDefaultAction();
  185. }