[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/libraries/src/MVC/Controller/ -> BaseController.php (summary)

Joomla! Content Management System

Copyright: (C) 2006 Open Source Matters, Inc.
License: GNU General Public License version 2 or later; see LICENSE.txt
File Size: 1064 lines (33 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

BaseController:: (26 methods):
  addModelPath()
  createFileName()
  getInstance()
  __construct()
  addPath()
  addViewPath()
  checkEditId()
  createModel()
  createView()
  display()
  execute()
  getModel()
  getName()
  getTask()
  getTasks()
  getView()
  holdEditId()
  redirect()
  registerDefaultTask()
  registerTask()
  unregisterTask()
  releaseEditId()
  setMessage()
  setPath()
  checkToken()
  setRedirect()


Class: BaseController  - X-Ref

Base class for a Joomla Controller

Controller (Controllers are where you put all the actual code.) Provides basic
functionality, such as rendering views (aka displaying templates).

addModelPath($path, $prefix = '')   X-Ref
Adds to the stack of model paths in LIFO order.

param: mixed   $path    The directory (string), or list of directories (array) to add.
param: string  $prefix  A prefix for models
return: void

createFileName($type, $parts = array()   X-Ref
Create the filename for a resource.

param: string  $type   The resource type to create the filename for.
param: array   $parts  An associative array of filename information. Optional.
return: string  The filename.

getInstance($prefix, $config = array()   X-Ref
Method to get a singleton controller instance.

param: string  $prefix  The prefix for the controller.
param: array   $config  An array of optional constructor options.
return: static

__construct($config = array()   X-Ref
Constructor.

param: array                $config   An optional associative array of configuration settings.
param: MVCFactoryInterface  $factory  The factory.
param: CMSApplication       $app      The Application for the dispatcher
param: Input                $input    Input

addPath($type, $path)   X-Ref
Adds to the search path for templates and resources.

param: string  $type  The path type (e.g. 'model', 'view').
param: mixed   $path  The directory string  or stream array to search.
return: static  A \JControllerLegacy object to support chaining.

addViewPath($path)   X-Ref
Add one or more view paths to the controller's stack, in LIFO order.

param: mixed  $path  The directory (string) or list of directories (array) to add.
return: static  This object to support chaining.

checkEditId($context, $id)   X-Ref
Method to check whether an ID is in the edit list.

param: string   $context  The context for the session storage.
param: integer  $id       The ID of the record to add to the edit list.
return: boolean  True if the ID is in the edit list.

createModel($name, $prefix = '', $config = array()   X-Ref
Method to load and return a model object.

param: string  $name    The name of the model.
param: string  $prefix  Optional model prefix.
param: array   $config  Configuration array for the model. Optional.
return: BaseDatabaseModel|boolean   Model object on success; otherwise false on failure.

createView($name, $prefix = '', $type = '', $config = array()   X-Ref
Method to load and return a view object. This method first looks in the
current template directory for a match and, failing that, uses a default
set path to load the view class file.

Note the "name, prefix, type" order of parameters, which differs from the
"name, type, prefix" order used in related public methods.

param: string  $name    The name of the view.
param: string  $prefix  Optional prefix for the view class name.
param: string  $type    The type of view.
param: array   $config  Configuration array for the view. Optional.
return: ViewInterface|null  View object on success; null or error result on failure.

display($cachable = false, $urlparams = array()   X-Ref
Typical view method for MVC based architecture

This function is provide as a default implementation, in most cases
you will need to override it in your own controllers.

param: boolean  $cachable   If true, the view output will be cached
param: array    $urlparams  An array of safe url parameters and their variable types, for valid values see {@link InputFilter::clean()}.
return: static  A \JControllerLegacy object to support chaining.

execute($task)   X-Ref
Execute a task by triggering a method in the derived class.

param: string  $task  The task to perform. If no matching task is found, the '__default' task is executed, if defined.
return: mixed   The value returned by the called method.

getModel($name = '', $prefix = '', $config = array()   X-Ref
Method to get a model object, loading it if required.

param: string  $name    The model name. Optional.
param: string  $prefix  The class prefix. Optional.
param: array   $config  Configuration array for model. Optional.
return: BaseDatabaseModel|boolean  Model object on success; otherwise false on failure.

getName()   X-Ref
Method to get the controller name

The dispatcher name is set by default parsed using the classname, or it can be set
by passing a $config['name'] in the class constructor

return: string  The name of the dispatcher

getTask()   X-Ref
Get the last task that is being performed or was most recently performed.

return: string  The task that is being performed or was most recently performed.

getTasks()   X-Ref
Gets the available tasks in the controller.

return: array  Array[i] of task names.

getView($name = '', $type = '', $prefix = '', $config = array()   X-Ref
Method to get a reference to the current view and load it if necessary.

param: string  $name    The view name. Optional, defaults to the controller name.
param: string  $type    The view type. Optional.
param: string  $prefix  The class prefix. Optional.
param: array   $config  Configuration array for view. Optional.
return: ViewInterface  Reference to the view or an error.

holdEditId($context, $id)   X-Ref
Method to add a record ID to the edit list.

param: string   $context  The context for the session storage.
param: integer  $id       The ID of the record to add to the edit list.
return: void

redirect()   X-Ref
Redirects the browser or returns false if no redirect is set.

return: boolean  False if no redirect exists.

registerDefaultTask($method)   X-Ref
Register the default task to perform if a mapping is not found.

param: string  $method  The name of the method in the derived class to perform if a named task is not found.
return: static  A \JControllerLegacy object to support chaining.

registerTask($task, $method)   X-Ref
Register (map) a task to a method in the class.

param: string  $task    The task.
param: string  $method  The name of the method in the derived class to perform for this task.
return: static  A \JControllerLegacy object to support chaining.

unregisterTask($task)   X-Ref
Unregister (unmap) a task in the class.

param: string  $task  The task.
return: static  This object to support chaining.

releaseEditId($context, $id)   X-Ref
Method to check whether an ID is in the edit list.

param: string   $context  The context for the session storage.
param: integer  $id       The ID of the record to add to the edit list.
return: void

setMessage($text, $type = 'message')   X-Ref
Sets the internal message that is passed with a redirect

param: string  $text  Message to display on redirect.
param: string  $type  Message type. Optional, defaults to 'message'.
return: string  Previous message

setPath($type, $path)   X-Ref
Sets an entire array of search paths for resources.

param: string  $type  The type of path to set, typically 'view' or 'model'.
param: string  $path  The new set of search paths. If null or false, resets to the current directory only.
return: void

checkToken($method = 'post', $redirect = true)   X-Ref
Checks for a form token in the request.

Use in conjunction with HTMLHelper::_('form.token') or Session::getFormToken.

param: string   $method    The request method in which to look for the token key.
param: boolean  $redirect  Whether to implicitly redirect user to the referrer page on failure or simply return false.
return: boolean  True if found and valid, otherwise return false or redirect to referrer page.

setRedirect($url, $msg = null, $type = null)   X-Ref
Set a URL for browser redirection.

param: string  $url   URL to redirect to.
param: string  $msg   Message to display on redirect. Optional, defaults to value set internally by controller, if any.
param: string  $type  Message type. Optional, defaults to 'message' or the type set by a previous call to setMessage.
return: static  This object to support chaining.



Generated: Wed Sep 7 05:41:13 2022 Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer