Controller Class Reference

Inheritance diagram for Controller:

Object AppController AppController CakeErrorController PagesController PagesController CakeErrorController PagesController PagesController List of all members.

Public Member Functions

 __construct ()
 __mergeVars ()
 _afterScaffoldSave ($method)
 _afterScaffoldSaveError ($method)
 _beforeScaffold ($method)
 _scaffoldError ($method)
 afterFilter ()
 beforeFilter ()
 beforeRender ()
 constructClasses ()
 disableCache ()
 flash ($message, $url, $pause=1)
 header ($status)
 isAuthorized ()
 loadModel ($modelClass=null, $id=null)
 paginate ($object=null, $scope=array(), $whitelist=array())
 postConditions ($data=array(), $op=null, $bool= 'AND', $exclusive=false)
 redirect ($url, $status=null, $exit=true)
 referer ($default=null, $local=false)
 render ($action=null, $layout=null, $file=null)
 set ($one, $two=null)
 setAction ($action)
 validate ()
 validateErrors ()

Public Attributes

 $action = null
 $autoLayout = true
 $autoRender = true
 $base = null
 $cacheAction = false
 $Component = null
 $components = array()
 $data = array()
 $ext = '.ctp'
 $helpers = array('Html', 'Form')
 $here = null
 $layout = 'default'
 $layoutPath = null
 $methods = array()
 $modelClass = null
 $modelKey = null
 $modelNames = array()
 $name = null
 $output = null
 $pageTitle = false
 $paginate = array('limit' => 20, 'page' => 1)
 $params = array()
 $passedArgs = array()
 $persistModel = false
 $plugin = null
 $scaffold = false
 $uses = false
 $validationErrors = null
 $view = 'View'
 $viewPath = null
 $viewVars = array()
 $webroot = null

Detailed Description

Definition at line 41 of file controller.php.


Constructor & Destructor Documentation

Controller::__construct (  ) 

Constructor.

Reimplemented from Object.

Reimplemented in CakeErrorController.

Definition at line 324 of file controller.php.

References __(), __construct(), classify(), name(), and underscore().


Member Function Documentation

Controller::__mergeVars (  ) 

Merge components, helpers, and uses vars from AppController and PluginAppController.

Returns:
void protected

Definition at line 359 of file controller.php.

References $plugin, $uses, camelize(), Set::merge(), Set::normalize(), and uses().

Referenced by constructClasses().

Controller::_afterScaffoldSave ( method  ) 

This method should be overridden in child classes.

Parameters:
string $method name of method called either edit or update.
Returns:
boolean Success protected http://book.cakephp.org/view/60/Callbacks

Definition at line 1150 of file controller.php.

Controller::_afterScaffoldSaveError ( method  ) 

This method should be overridden in child classes.

Parameters:
string $method name of method called either edit or update.
Returns:
boolean Success protected http://book.cakephp.org/view/60/Callbacks

Definition at line 1161 of file controller.php.

Controller::_beforeScaffold ( method  ) 

This method should be overridden in child classes.

Parameters:
string $method name of method called example index, edit, etc.
Returns:
boolean Success protected http://book.cakephp.org/view/60/Callbacks

Definition at line 1139 of file controller.php.

Controller::_scaffoldError ( method  ) 

This method should be overridden in child classes. If not it will render a scaffold error. Method MUST return true in child classes

Parameters:
string $method name of method called example index, edit, etc.
Returns:
boolean Success protected http://book.cakephp.org/view/60/Callbacks

Definition at line 1174 of file controller.php.

Controller::afterFilter (  ) 

Called after the controller action is run and rendered.

public http://book.cakephp.org/view/60/Callbacks

Definition at line 1129 of file controller.php.

Controller::beforeFilter (  ) 

Called before the controller action.

public http://book.cakephp.org/view/60/Callbacks

Definition at line 1113 of file controller.php.

Controller::beforeRender (  ) 

Called after the controller action is run, but before the view is rendered.

public http://book.cakephp.org/view/60/Callbacks

Definition at line 1121 of file controller.php.

Referenced by render().

Controller::constructClasses (  ) 

Loads Model classes based on the the uses property see Controller::loadModel(); for more info. Loads Components and prepares them for initialization.

Returns:
mixed true if models found and instance created, or cakeError if models not found. public
See also:
Controller::loadModel() http://book.cakephp.org/view/429/constructClasses

Definition at line 440 of file controller.php.

References $id, $modelClass, $plugin, $uses, __mergeVars(), loadModel(), and uses().

Referenced by CakeErrorController::__construct().

Controller::disableCache (  ) 

Forces the user's browser not to cache the results of the current request.

Returns:
void public http://book.cakephp.org/view/431/disableCache

Definition at line 843 of file controller.php.

References header().

Controller::flash ( message,
url,
pause = 1 
)

Shows a message to the user for $pause seconds, then redirects to $url. Uses flash.ctp as the default layout for the message. Does not work if the current debug level is higher than 0.

Parameters:
string $message Message to display to the user
mixed $url Relative string or array-based URL to redirect to after the time expires
integer $pause Time to show the message
Returns:
void Renders flash layout public http://book.cakephp.org/view/426/flash

Definition at line 862 of file controller.php.

References $url, render(), set(), and Router::url().

Controller::header ( status  ) 

Convenience method for header()

Parameters:
string $status
Returns:
void public

Definition at line 643 of file controller.php.

Referenced by disableCache(), and redirect().

Controller::isAuthorized (  ) 

Controller callback to tie into Auth component. Only called when AuthComponent::authorize is set to 'controller'.

Returns:
bool true if authorized, false otherwise public http://book.cakephp.org/view/396/authorize

Definition at line 706 of file controller.php.

References __().

Controller::loadModel ( modelClass = null,
id = null 
)

Loads and instantiates models required by this controller. If Controller::persistModel; is true, controller will create cached model instances on first request, additional request will used cached models. If the model is non existent, it will throw a missing database table error, as Cake generates dynamic models for the time being.

Parameters:
string $modelClass Name of model class to load
mixed $id Initial ID the instanced model class should have
Returns:
mixed true when single model found and instance created error returned if models not found. public

Definition at line 479 of file controller.php.

References $id, $modelClass, $plugin, Object::_persist(), Object::cakeError(), ClassRegistry::getInstance(), ClassRegistry::init(), and uses().

Referenced by constructClasses().

Controller::paginate ( object = null,
scope = array(),
whitelist = array() 
)

Handles automatic pagination of model records.

Parameters:
mixed $object Model to paginate (e.g: model instance, or 'Model', or 'Model.InnerModel')
mixed $scope Conditions to use while paginating
array $whitelist List of allowed options for paging
Returns:
array Model query results public http://book.cakephp.org/view/165/Controller-Setup

Definition at line 934 of file controller.php.

References $name, __(), name(), order, params(), and uses().

Controller::postConditions ( data = array(),
op = null,
bool = 'AND',
exclusive = false 
)

Converts POST'ed form data to a model conditions array, suitable for use in a Model::find() call.

Parameters:
array $data POST'ed data organized by model and field
mixed $op A string containing an SQL comparison operator, or an array matching operators to fields
string $bool SQL boolean operator: AND, OR, XOR, etc.
boolean $exclusive If true, and $op is an array, fields not included in $op will not be included in the returned conditions
Returns:
array An array of model conditions public http://book.cakephp.org/view/432/postConditions

Definition at line 881 of file controller.php.

References $data.

Controller::redirect ( url,
status = null,
exit = true 
)

Redirects to given $url, after turning off $this->autoRender. Script execution is halted after the redirect.

Parameters:
mixed $url A string or array-based URL pointing to another location within the app, or an absolute URL
integer $status Optional HTTP status code (eg: 404)
boolean $exit If true, exit() will be called after the redirect
Returns:
mixed void if $exit = false. Terminates script if $exit = true public http://book.cakephp.org/view/425/redirect

Definition at line 536 of file controller.php.

References $url, Object::_stop(), header(), and Router::url().

Referenced by PagesController::display().

Controller::referer ( default = null,
local = false 
)

Returns the referring URL for this request.

Parameters:
string $default Default URL to use if HTTP_REFERER cannot be read from headers
boolean $local If true, restrict referring URLs to local server
Returns:
string Referring URL public http://book.cakephp.org/view/430/referer

Definition at line 816 of file controller.php.

References $base, and env().

Controller::render ( action = null,
layout = null,
file = null 
)

Instantiates the correct view class, hands it its data, and uses it to render the view output.

Parameters:
string $action Action name to render
string $layout Layout to use
string $file File to use for rendering
Returns:
string Full output string of view contents public http://book.cakephp.org/view/428/render

Definition at line 759 of file controller.php.

References $action, $layout, $plugin, beforeRender(), camelize(), ClassRegistry::getObject(), App::import(), ClassRegistry::isKeySet(), ClassRegistry::keys(), params(), Configure::read(), set(), and underscore().

Referenced by PagesController::display(), and flash().

Controller::set ( one,
two = null 
)

Saves a variable for use inside a view template.

Parameters:
mixed $one A string or an array of data.
mixed $two Value in case $one is a string (which then works as the key). Unused if $one is an associative array, otherwise serves as the values to $one's keys.
Returns:
void public http://book.cakephp.org/view/427/set

Definition at line 656 of file controller.php.

References $data, $name, and variable().

Referenced by PagesController::display(), flash(), and render().

Controller::setAction ( action  ) 

Internally redirects one action to another. Examples:

setAction('another_action'); setAction('action_with_parameters', $parameter1);

Parameters:
string $action The new action to be redirected to
mixed Any other parameters passed to this method will be passed as parameters to the new action.
Returns:
mixed Returns the return value of the called action public

Definition at line 693 of file controller.php.

References $action.

Controller::validate (  ) 

Returns number of errors in a submitted FORM.

Returns:
integer Number of errors public

Definition at line 716 of file controller.php.

References validateErrors().

Controller::validateErrors (  ) 

Validates models passed by parameters. Example:

$errors = $this->validateErrors($this->Article, $this->User);

Parameters:
mixed A list of models as a variable argument
Returns:
array Validation errors, or false if none public

Definition at line 734 of file controller.php.

Referenced by validate().


Member Data Documentation

Controller::$action = null

Definition at line 70 of file controller.php.

Referenced by render(), and setAction().

Controller::$autoLayout = true

Definition at line 195 of file controller.php.

Controller::$autoRender = true

Definition at line 188 of file controller.php.

Controller::$base = null

Definition at line 170 of file controller.php.

Referenced by referer().

Controller::$cacheAction = false

Definition at line 261 of file controller.php.

Controller::$Component = null

Definition at line 202 of file controller.php.

Controller::$components = array()

Definition at line 213 of file controller.php.

Referenced by AuthComponent::startup().

Controller::$data = array()

Definition at line 108 of file controller.php.

Referenced by postConditions(), and set().

Controller::$ext = '.ctp'

Definition at line 227 of file controller.php.

Controller::$helpers = array('Html', 'Form')

Reimplemented in PagesController.

Definition at line 91 of file controller.php.

Controller::$here = null

Definition at line 56 of file controller.php.

Controller::$layout = 'default'

Definition at line 180 of file controller.php.

Referenced by render().

Controller::$layoutPath = null

Definition at line 140 of file controller.php.

Controller::$methods = array()

Definition at line 293 of file controller.php.

Controller::$modelClass = null

Definition at line 303 of file controller.php.

Referenced by constructClasses(), and loadModel().

Controller::$modelKey = null

Definition at line 312 of file controller.php.

Controller::$modelNames = array()

Definition at line 163 of file controller.php.

Controller::$name = null

Reimplemented in PagesController, and CakeErrorController.

Definition at line 49 of file controller.php.

Referenced by paginate(), and set().

Controller::$output = null

Definition at line 236 of file controller.php.

Controller::$pageTitle = false

Definition at line 156 of file controller.php.

Controller::$paginate = array('limit' => 20, 'page' => 1)

Definition at line 126 of file controller.php.

Controller::$params = array()

Definition at line 100 of file controller.php.

Controller::$passedArgs = array()

Definition at line 277 of file controller.php.

Controller::$persistModel = false

Definition at line 270 of file controller.php.

Controller::$plugin = null

Definition at line 243 of file controller.php.

Referenced by __mergeVars(), constructClasses(), loadModel(), and render().

Controller::$scaffold = false

Definition at line 285 of file controller.php.

Controller::$uses = false

Reimplemented in PagesController, and CakeErrorController.

Definition at line 80 of file controller.php.

Referenced by __mergeVars(), and constructClasses().

Controller::$validationErrors = null

Definition at line 319 of file controller.php.

Controller::$view = 'View'

Definition at line 220 of file controller.php.

Controller::$viewPath = null

Definition at line 133 of file controller.php.

Controller::$viewVars = array()

Definition at line 147 of file controller.php.

Controller::$webroot = null

Definition at line 63 of file controller.php.


The documentation for this class was generated from the following file:
Generated on Sun Nov 22 00:30:55 2009 for CakePHP 1.2.x.x (v1.2.4.8284) by doxygen 1.4.7