Joomla! CMS 3.3 API

JControllerLegacy

Extends \JObject

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

package

Joomla.Legacy

subpackage

Controller

since

12.2

Methods

__construct

Class constructor, overridden in descendant classes.

__construct(mixed $properties = null) 
inherited
since

11.1

Arguments

$properties

mixedEither and associative array or another

                         object to set the initial properties of the object.

__toString

Magic method to convert the object to a string gracefully.

__toString() : string
inherited
since

11.1

deprecated

12.3 Classes should provide their own __toString() implementation.

Response

stringThe classname.

addModelPath

Adds to the stack of model paths in LIFO order.

addModelPath(mixed $path, string $prefix = '') : void
static

Arguments

$path

mixedThe directory (string), or list of directories (array) to add.

$prefix

stringA prefix for models

addPath

Adds to the search path for templates and resources.

addPath(string $type, mixed $path) : \JControllerLegacy
since

12.2

note

Replaces _addPath.

Arguments

$type

stringThe path type (e.g. 'model', 'view').

$path

mixedThe directory string or stream array to search.

Response

\JControllerLegacyA JControllerLegacy object to support chaining.

addViewPath

Add one or more view paths to the controller's stack, in LIFO order.

addViewPath(mixed $path) : \JControllerLegacy

Arguments

$path

mixedThe directory (string) or list of directories (array) to add.

Response

\JControllerLegacyThis object to support chaining.

authorise

Authorisation check

authorise(string $task) : boolean
since

12.2

deprecated

13.3 Use JAccess instead.

Arguments

$task

stringThe ACO Section Value to check access on.

Response

booleanTrue if authorised

checkEditId

Method to check whether an ID is in the edit list.

checkEditId(string $context, integer $id) : boolean
since

12.2

Arguments

$context

stringThe context for the session storage.

$id

integerThe ID of the record to add to the edit list.

Response

booleanTrue if the ID is in the edit list.

createFileName

Create the filename for a resource.

createFileName(string $type, array $parts = array()) : string
static
note

Replaced _createFileName.

since

12.2

Arguments

$type

stringThe resource type to create the filename for.

$parts

arrayAn associative array of filename information. Optional.

Response

stringThe filename.

createModel

Method to load and return a model object.

createModel(string $name, string $prefix = '', array $config = array()) : mixed
since

12.2

note

Replaces _createModel.

Arguments

$name

stringThe name of the model.

$prefix

stringOptional model prefix.

$config

arrayConfiguration array for the model. Optional.

Response

mixedModel object on success; otherwise null failure.

createView

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.

createView(string $name, string $prefix = '', string $type = '', array $config = array()) : mixed

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

since

12.2

note

Replaces _createView.

throws

\Exception

Arguments

$name

stringThe name of the view.

$prefix

stringOptional prefix for the view class name.

$type

stringThe type of view.

$config

arrayConfiguration array for the view. Optional.

Response

mixedView object on success; null or error result on failure.

def

Sets a default value if not alreay assigned

def(string $property, mixed $default = null) : mixed
inherited
since

11.1

Arguments

$property

stringThe name of the property.

$default

mixedThe default value.

Response

mixed

display

Typical view method for MVC based architecture

display(boolean $cachable = false, array $urlparams = array()) : \JControllerLegacy

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

since

12.2

Arguments

$cachable

booleanIf true, the view output will be cached

$urlparams

arrayAn array of safe url parameters and their variable types, for valid values see {@link JFilterInput::clean()}.

Response

\JControllerLegacyA JControllerLegacy object to support chaining.

execute

Execute a task by triggering a method in the derived class.

execute(string $task) : mixed
since

12.2

throws

\Exception

Arguments

$task

stringThe task to perform. If no matching task is found, the '__default' task is executed, if defined.

Response

mixedThe value returned by the called method, false in error case.

get

Returns a property of the object or the default value if the property is not set.

get(string $property, mixed $default = null) : mixed
inherited
since

11.1

see \JObject::getProperties()

Arguments

$property

stringThe name of the property.

$default

mixedThe default value.

Response

mixedThe value of the property.

getError

Get the most recent error message.

getError(integer $i = null, boolean $toString = true) : string
inherited
since

11.1

see \JError
deprecated

12.3 JError has been deprecated

Arguments

$i

integerOption error index.

$toString

booleanIndicates if JError objects should return their error message.

Response

stringError message

getErrors

Return all errors, if any.

getErrors() : array
inherited
since

11.1

see \JError
deprecated

12.3 JError has been deprecated

Response

arrayArray of error messages or JErrors.

getInstance

Method to get a singleton controller instance.

getInstance(string $prefix, array $config = array()) : \JControllerLegacy
static
since

12.2

throws

\Exceptionif the controller cannot be loaded.

Arguments

$prefix

stringThe prefix for the controller.

$config

arrayAn array of optional constructor options.

Response

\JControllerLegacy

getModel

Method to get a model object, loading it if required.

getModel(string $name = '', string $prefix = '', array $config = array()) : object
since

12.2

Arguments

$name

stringThe model name. Optional.

$prefix

stringThe class prefix. Optional.

$config

arrayConfiguration array for model. Optional.

Response

objectThe model.

getName

Method to get the controller name

getName() : string

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

since

12.2

throws

\Exception

Response

stringThe name of the dispatcher

getProperties

Returns an associative array of object properties.

getProperties(boolean $public = true) : array
inherited
since

11.1

see \JObject::get()

Arguments

$public

booleanIf true, returns only the public properties.

Response

array

getTask

Get the last task that is being performed or was most recently performed.

getTask() : string
since

12.2

Response

stringThe task that is being performed or was most recently performed.

getTasks

Gets the available tasks in the controller.

getTasks() : array
since

12.2

Response

arrayArray[i] of task names.

getView

Method to get a reference to the current view and load it if necessary.

getView(string $name = '', string $type = '', string $prefix = '', array $config = array()) : \JViewLegacy
since

12.2

throws

\Exception

Arguments

$name

stringThe view name. Optional, defaults to the controller name.

$type

stringThe view type. Optional.

$prefix

stringThe class prefix. Optional.

$config

arrayConfiguration array for view. Optional.

Response

\JViewLegacyReference to the view or an error.

holdEditId

Method to add a record ID to the edit list.

holdEditId(string $context, integer $id) : void
since

12.2

Arguments

$context

stringThe context for the session storage.

$id

integerThe ID of the record to add to the edit list.

redirect

Redirects the browser or returns false if no redirect is set.

redirect() : boolean
since

12.2

Response

booleanFalse if no redirect exists.

registerDefaultTask

Register the default task to perform if a mapping is not found.

registerDefaultTask(string $method) : \JControllerLegacy
since

12.2

Arguments

$method

stringThe name of the method in the derived class to perform if a named task is not found.

Response

\JControllerLegacyA JControllerLegacy object to support chaining.

registerTask

Register (map) a task to a method in the class.

registerTask(string $task, string $method) : \JControllerLegacy
since

12.2

Arguments

$task

stringThe task.

$method

stringThe name of the method in the derived class to perform for this task.

Response

\JControllerLegacyA JControllerLegacy object to support chaining.

releaseEditId

Method to check whether an ID is in the edit list.

releaseEditId(string $context, integer $id) : void
since

12.2

Arguments

$context

stringThe context for the session storage.

$id

integerThe ID of the record to add to the edit list.

set

Modifies a property of the object, creating it if it does not already exist.

set(string $property, mixed $value = null) : mixed
inherited
since

11.1

Arguments

$property

stringThe name of the property.

$value

mixedThe value of the property to set.

Response

mixedPrevious value of the property.

setError

Add an error message.

setError(string $error) : void
inherited
since

11.1

see \JError
deprecated

12.3 JError has been deprecated

Arguments

$error

stringError message.

setMessage

Sets the internal message that is passed with a redirect

setMessage(string $text, string $type = 'message') : string
since

12.2

Arguments

$text

stringMessage to display on redirect.

$type

stringMessage type. Optional, defaults to 'message'.

Response

stringPrevious message

setPath

Sets an entire array of search paths for resources.

setPath(string $type, string $path) : void
note

Replaces _setPath.

since

12.2

Arguments

$type

stringThe type of path to set, typically 'view' or 'model'.

$path

stringThe new set of search paths. If null or false, resets to the current directory only.

setProperties

Set the object properties based on a named array/hash.

setProperties(mixed $properties) : boolean
inherited
since

11.1

see \JObject::set()

Arguments

$properties

mixedEither an associative array or another object.

Response

boolean

setRedirect

Set a URL for browser redirection.

setRedirect(string $url, string $msg = null, string $type = null) : \JControllerLegacy
since

12.2

Arguments

$url

stringURL to redirect to.

$msg

stringMessage to display on redirect. Optional, defaults to value set internally by controller, if any.

$type

stringMessage type. Optional, defaults to 'message' or the type set by a previous call to setMessage.

Response

\JControllerLegacyThis object to support chaining.

unregisterTask

Unregister (unmap) a task in the class.

unregisterTask(string $task) : \JControllerLegacy
since

12.2

Arguments

$task

stringThe task.

Response

\JControllerLegacyThis object to support chaining.

Properties

basePath

The base path of the controller

basePath : string
var
since

12.2

note

Replaces _basePath.

Type(s)

string

default_view

The default view for the display method.

default_view : string
var
since

12.2

Type(s)

string

doTask

The mapped task that was performed.

doTask : string
var
since

12.2

note

Replaces _doTask.

Type(s)

string

message

Redirect message.

message : string
var
since

12.2

note

Replaces _message.

Type(s)

string

messageType

Redirect message type.

messageType : string
var
since

12.2

note

Replaces _messageType.

Type(s)

string

methods

Array of class methods

methods : array
var
since

12.2

note

Replaces _methods.

Type(s)

array

name

The name of the controller

name : array
var
since

12.2

note

Replaces _name.

Type(s)

array

model_prefix

The prefix of the models

model_prefix : string
var
since

12.2

Type(s)

string

paths

The set of search directories for resources (views).

paths : array
var
since

12.2

note

Replaces _path.

Type(s)

array

redirect

URL for redirection.

redirect : string
var
since

12.2

note

Replaces _redirect.

Type(s)

string

task

Current or most recently performed task.

task : string
var
since

12.2

note

Replaces _task.

Type(s)

string

taskMap

Array of class methods to call for a given task.

taskMap : array
var
since

12.2

note

Replaces _taskMap.

Type(s)

array

input

Hold a JInput object for easier access to the input variables.

input : \JInput
var
since

12.2

Type(s)

\JInput

instance

Instance container.

instance : \JControllerLegacy
static
var
since

12.2

Type(s)

\JControllerLegacy

views

Instance container containing the views.

views : array
static
var
since

3.4

Type(s)

array

_errors

An array of error messages or Exception objects.

_errors : array
inherited
var
since

11.1

see \JError
deprecated

12.3 JError has been deprecated

Type(s)

array