Back to Joomla project (class list)

Class BaseController - list of methods

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

Extends

Direct known subclasses

Package: Joomla\CMS\MVC\Controller
Copyright: (C) 2006 Open Source Matters, Inc.
License: GNU General Public License version 2 or later; see LICENSE.txt
Located at: Joomla/MVC/Controller/BaseController.php
Project: Joomla

Method Summary

public static void
(mixed $path, mixed $prefix = '')

Adds to the stack of model paths in LIFO order.
Parameters
  • mixed $path The directory (string), or list of directories (array) to add.
  • string $prefix A prefix for models
Returns
  • void
Since
  • 3.0
Deprecated
  • 5.0
Show source code of this method: addModelPath Source Code

public static string
(mixed $type, mixed $parts = array())

Create the filename for a resource.
Parameters
  • string $type The resource type to create the filename for.
  • array $parts An associative array of filename information. Optional.
Returns
  • string The filename.
Since
  • 3.0
Show source code of this method: createFileName Source Code

public static static
(mixed $prefix, mixed $config = array())

Method to get a singleton controller instance.
Parameters
  • string $prefix The prefix for the controller.
  • array $config An array of optional constructor options.
Returns
  • static
Since
  • 3.0
Deprecated
  • 5.0
-
  • \Exception if the controller cannot be loaded.
Show source code of this method: getInstance Source Code

public
(mixed $config = array(), \Joomla\CMS\MVC\Factory\MVCFactoryInterface $factory = null, ?\Joomla\CMS\Application\CMSApplication $app = null, ?\Joomla\Input\Input $input = null)

Constructor.
Parameters
  • array $config An optional associative array of configuration settings. Recognized key values include 'name', 'default_task', 'model_path', and 'view_path' (this list is not meant to be comprehensive).
  • \Joomla\CMS\MVC\Factory\MVCFactoryInterface $factory The factory.
  • \Joomla\CMS\Application\CMSApplication $app The Application for the dispatcher
  • \Joomla\Input\Input $input Input
Since
  • 3.0
Show source code of this method: __construct Source Code

protected static
(mixed $type, mixed $path)

Adds to the search path for templates and resources.
Parameters
  • string $type The path type (e.g. 'model', 'view').
  • mixed $path The directory string or stream array to search.
Returns
  • static A \JControllerLegacy object to support chaining.
Since
  • 3.0
Show source code of this method: addPath Source Code

public static
(mixed $path)

Add one or more view paths to the controller's stack, in LIFO order.
Parameters
  • mixed $path The directory (string) or list of directories (array) to add.
Returns
  • static This object to support chaining.
Since
  • 3.0
Show source code of this method: addViewPath Source Code

protected bool
(mixed $context, mixed $id)

Method to check whether an ID is in the edit list.
Parameters
  • string $context The context for the session storage.
  • int $id The ID of the record to add to the edit list.
Returns
  • bool True if the ID is in the edit list.
Since
  • 3.0
Show source code of this method: checkEditId Source Code

protected \Joomla\CMS\MVC\Model\BaseDatabaseModel|bool
(mixed $name, mixed $prefix = '', mixed $config = array())

Method to load and return a model object.
Parameters
  • string $name The name of the model.
  • string $prefix Optional model prefix.
  • array $config Configuration array for the model. Optional.
Returns
  • \Joomla\CMS\MVC\Model\BaseDatabaseModel|bool Model object on success; otherwise false on failure.
Since
  • 3.0
Show source code of this method: createModel Source Code

protected \Joomla\CMS\MVC\View\ViewInterface|null
(mixed $name, mixed $prefix = '', mixed $type = '', mixed $config = array())

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.
Parameters
  • string $name The name of the view.
  • string $prefix Optional prefix for the view class name.
  • string $type The type of view.
  • array $config Configuration array for the view. Optional.
Returns
  • \Joomla\CMS\MVC\View\ViewInterface|null View object on success; null or error result on failure.
Since
  • 3.0
-
  • \Exception
Show source code of this method: createView Source Code

public static
(mixed $cachable = false, mixed $urlparams = array())

Typical view method for MVC based architecture
Parameters
  • bool $cachable If true, the view output will be cached
  • array $urlparams An array of safe url parameters and their variable types, for valid values see {@link InputFilter::clean()}.
Returns
  • static A \JControllerLegacy object to support chaining.
Since
  • 3.0
-
  • \Exception
Show source code of this method: display Source Code

public mixed
(mixed $task)

Execute a task by triggering a method in the derived class.
Parameters
  • string $task The task to perform. If no matching task is found, the '__default' task is executed, if defined.
Returns
  • mixed The value returned by the called method.
Since
  • 3.0
-
  • \Exception
Show source code of this method: execute Source Code

public \Joomla\CMS\MVC\Model\BaseDatabaseModel|bool
(mixed $name = '', mixed $prefix = '', mixed $config = array())

Method to get a model object, loading it if required.
Parameters
  • string $name The model name. Optional.
  • string $prefix The class prefix. Optional.
  • array $config Configuration array for model. Optional.
Returns
  • \Joomla\CMS\MVC\Model\BaseDatabaseModel|bool Model object on success; otherwise false on failure.
Since
  • 3.0
Show source code of this method: getModel Source Code

public string
()

Method to get the controller name
Returns
  • string The name of the dispatcher
Since
  • 3.0
-
  • \Exception
Show source code of this method: getName Source Code

public string
()

Get the last task that is being performed or was most recently performed.
Returns
  • string The task that is being performed or was most recently performed.
Since
  • 3.0
Show source code of this method: getTask Source Code

public array
()

Gets the available tasks in the controller.
Returns
  • array Array[i] of task names.
Since
  • 3.0
Show source code of this method: getTasks Source Code

public \Joomla\CMS\MVC\View\ViewInterface
(mixed $name = '', mixed $type = '', mixed $prefix = '', mixed $config = array())

Method to get a reference to the current view and load it if necessary.
Parameters
  • string $name The view name. Optional, defaults to the controller name.
  • string $type The view type. Optional.
  • string $prefix The class prefix. Optional.
  • array $config Configuration array for view. Optional.
Returns
  • \Joomla\CMS\MVC\View\ViewInterface Reference to the view or an error.
Since
  • 3.0
-
  • \Exception
Show source code of this method: getView Source Code

protected void
(mixed $context, mixed $id)

Method to add a record ID to the edit list.
Parameters
  • string $context The context for the session storage.
  • int $id The ID of the record to add to the edit list.
Returns
  • void
Since
  • 3.0
Show source code of this method: holdEditId Source Code

public bool
()

Redirects the browser or returns false if no redirect is set.
Returns
  • bool False if no redirect exists.
Since
  • 3.0
Show source code of this method: redirect Source Code

public static
(mixed $method)

Register the default task to perform if a mapping is not found.
Parameters
  • string $method The name of the method in the derived class to perform if a named task is not found.
Returns
  • static A \JControllerLegacy object to support chaining.
Since
  • 3.0
Show source code of this method: registerDefaultTask Source Code

public static
(mixed $task, mixed $method)

Register (map) a task to a method in the class.
Parameters
  • string $task The task.
  • string $method The name of the method in the derived class to perform for this task.
Returns
  • static A \JControllerLegacy object to support chaining.
Since
  • 3.0
Show source code of this method: registerTask Source Code

public static
(mixed $task)

Unregister (unmap) a task in the class.
Parameters
  • string $task The task.
Returns
  • static This object to support chaining.
Since
  • 3.0
Show source code of this method: unregisterTask Source Code

protected void
(mixed $context, mixed $id)

Method to check whether an ID is in the edit list.
Parameters
  • string $context The context for the session storage.
  • int $id The ID of the record to add to the edit list.
Returns
  • void
Since
  • 3.0
Show source code of this method: releaseEditId Source Code

public string
(mixed $text, mixed $type = 'message')

Sets the internal message that is passed with a redirect
Parameters
  • string $text Message to display on redirect.
  • string $type Message type. Optional, defaults to 'message'.
Returns
  • string Previous message
Since
  • 3.0
Show source code of this method: setMessage Source Code

protected void
(mixed $type, mixed $path)

Sets an entire array of search paths for resources.
Parameters
  • string $type The type of path to set, typically 'view' or 'model'.
  • string $path The new set of search paths. If null or false, resets to the current directory only.
Returns
  • void
Since
  • 3.0
Show source code of this method: setPath Source Code

public bool
(mixed $method = 'post', mixed $redirect = true)

Checks for a form token in the request.
Parameters
  • string $method The request method in which to look for the token key.
  • bool $redirect Whether to implicitly redirect user to the referrer page on failure or simply return false.
Returns
  • bool True if found and valid, otherwise return false or redirect to referrer page.
Since
  • 3.7.0
-
  • \Joomla\CMS\Session\Session::checkToken()
Show source code of this method: checkToken Source Code

public static
(mixed $url, mixed $msg = null, mixed $type = null)

Set a URL for browser redirection.
Parameters
  • string $url URL to redirect to.
  • string $msg Message to display on redirect. Optional, defaults to value set internally by controller, if any.
  • string $type Message type. Optional, defaults to 'message' or the type set by a previous call to setMessage.
Returns
  • static This object to support chaining.
Since
  • 3.0
Show source code of this method: setRedirect Source Code

Properties Summary

protected string
$basePath
The base path of the controller
Since
  • 3.0
protected string
$default_view
The default view for the display method.
Since
  • 3.0
protected string
$doTask
The mapped task that was performed.
Since
  • 3.0
protected string
$message
Redirect message.
Since
  • 3.0
protected string
$messageType
Redirect message type.
Since
  • 3.0
protected array
$methods
Array of class methods
Since
  • 3.0
protected array
$name
The name of the controller
Since
  • 3.0
protected string
$model_prefix
The prefix of the models
Since
  • 3.0
protected array
$paths
The set of search directories for resources (views).
Since
  • 3.0
protected string
$redirect
URL for redirection.
Since
  • 3.0
protected string
$task
Current or most recently performed task.
Since
  • 3.0
protected array
$taskMap
Array of class methods to call for a given task.
Since
  • 3.0
protected \Joomla\Input\Input
$input
Hold a JInput object for easier access to the input variables.
Since
  • 3.0
protected \Joomla\CMS\MVC\Factory\MVCFactoryInterface
$factory
The factory.
Since
  • 3.10.0
protected static static
$instance
Instance container.
Since
  • 3.0
protected static \Joomla\CMS\MVC\View\ViewInterface[]
$views
Instance container containing the views.
Since
  • 3.4
protected \Joomla\CMS\Application\CMSApplication|null
$app
The Application
Since
  • 4.0.0

Tags Summary

Since
2.5.5