Adding documentation for Dispatcher

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@5297 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
mariano.iglesias 2007-06-19 13:28:55 +00:00
parent 934a2abb93
commit 75ccff3c3e

View file

@ -42,24 +42,37 @@
class Dispatcher extends Object { class Dispatcher extends Object {
/** /**
* Base URL * Base URL
*
* @var string * @var string
* @access public
*/ */
var $base = false; var $base = false;
/** /**
* Current URL * Current URL
*
* @var string * @var string
* @access public
*/ */
var $here = false; var $here = false;
/** /**
* Admin route (if on it)
*
* @var string * @var string
* @access public
*/ */
var $admin = false; var $admin = false;
/** /**
* Webservice route
*
* @var string * @var string
* @access public
*/ */
var $webservices = null; var $webservices = null;
/** /**
* Plugin being served (if any)
*
* @var string * @var string
* @access public
*/ */
var $plugin = null; var $plugin = null;
/** /**
@ -79,6 +92,7 @@ class Dispatcher extends Object {
* @param array $additionalParams Settings array ("bare", "return"), * @param array $additionalParams Settings array ("bare", "return"),
* which is melded with the GET and POST params. * which is melded with the GET and POST params.
* @return boolean Success * @return boolean Success
* @access public
*/ */
function dispatch($url, $additionalParams = array()) { function dispatch($url, $additionalParams = array()) {
$params = array_merge($this->parseParams($url), $additionalParams); $params = array_merge($this->parseParams($url), $additionalParams);
@ -323,12 +337,14 @@ class Dispatcher extends Object {
return $this->_invoke($controller, $params, $missingAction); return $this->_invoke($controller, $params, $missingAction);
} }
/** /**
* Invokes given controller's render action if autoRender option is set. Otherwise the contents of the operation are returned as a string. * Invokes given controller's render action if autoRender option is set. Otherwise the
* contents of the operation are returned as a string.
* *
* @param object $controller * @param object $controller Controller to invoke
* @param array $params * @param array $params Parameters with at least the 'action' to invoke
* @param boolean $missingAction * @param boolean $missingAction Set to true if missing action should be rendered, false otherwise
* @return string * @return string Output as sent by controller
* @access protected
*/ */
function _invoke (&$controller, $params, $missingAction = false) { function _invoke (&$controller, $params, $missingAction = false) {
$this->start($controller); $this->start($controller);
@ -358,9 +374,11 @@ class Dispatcher extends Object {
return $controller->output; return $controller->output;
} }
/** /**
* Starts up a controller * Starts up a controller (by calling its beforeFilter methods and
* starting its components)
* *
* @param object $controller * @param object $controller Controller to start
* @access public
*/ */
function start(&$controller) { function start(&$controller) {
if (!empty($controller->beforeFilter)) { if (!empty($controller->beforeFilter)) {
@ -393,14 +411,15 @@ class Dispatcher extends Object {
/** /**
* Returns array of GET and POST parameters. GET parameters are taken from given URL. * Returns array of GET and POST parameters. GET parameters are taken from given URL.
* *
* @param string $from_url URL to mine for parameter information. * @param string $fromUrl URL to mine for parameter information.
* @return array Parameters found in POST and GET. * @return array Parameters found in POST and GET.
* @access public
*/ */
function parseParams($from_url) { function parseParams($fromUrl) {
$Route = Router::getInstance(); $Route = Router::getInstance();
extract(Router::getNamedExpressions()); extract(Router::getNamedExpressions());
include CONFIGS.'routes.php'; include CONFIGS.'routes.php';
$params = Router::parse($from_url); $params = Router::parse($fromUrl);
if (ini_get('magic_quotes_gpc') == 1) { if (ini_get('magic_quotes_gpc') == 1) {
if(!empty($_POST)) { if(!empty($_POST)) {
@ -451,6 +470,7 @@ class Dispatcher extends Object {
* Returns a base URL. * Returns a base URL.
* *
* @return string Base URL * @return string Base URL
* @access public
*/ */
function baseUrl() { function baseUrl() {
$htaccess = null; $htaccess = null;
@ -504,10 +524,11 @@ class Dispatcher extends Object {
return $base; return $base;
} }
/** /**
* Enter description here... * Restructure params in case we're serving a plugin.
* *
* @param unknown_type $params * @param array $params Array on where to re-set 'controller', 'action', and 'pass' indexes
* @return unknown * @return array Restructured array
* @access protected
*/ */
function _restructureParams($params) { function _restructureParams($params) {
$params['controller'] = $params['action']; $params['controller'] = $params['action'];