JApplication

Extends \JObject

Base class for a Joomla! application.

Acts as a Factory class for application specific objects and provides many supporting API functions. Derived clases should supply the route(), dispatch() and render() functions.

package

Joomla.Platform

subpackage

Application

since

11.1

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 deprecated
since

11.1

deprecated

12.3 Classes should provide their own __toString() implementation.

Response

stringThe classname.

_createConfiguration

Create the configuration registry.

_createConfiguration(string $file) : object
since

11.1

Arguments

$file

stringThe path to the configuration file

Response

objectA JConfig object

_createSession

Create the user session.

_createSession(string $name) : \JSession

Old sessions are flushed based on the configuration value for the cookie lifetime. If an existing session, then the last access time is updated. If a new session, a session id is generated and a record is created in the #__sessions table.

since

11.1

Arguments

$name

stringThe sessions name.

Response

\JSessionJSession on success. May call exit() on database error.

checkSession

Checks the user session.

checkSession() : void

If the session record doesn't exist, initialise it. If session is new, create session variables

since

11.1

close

Exit the application.

close(integer $code) : void
since

11.1

Arguments

$code

integerExit code

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

dispatch

Dispatch the application.

dispatch(string $component = null) : void

Dispatching is the process of pulling the option from the request object and mapping them to a component. If the component does not exist, it handles determining a default component to dispatch.

since

11.1

Arguments

$component

stringThe component to dispatch.

enqueueMessage

Enqueue a system message.

enqueueMessage(string $msg, string $type = 'message') : void
since

11.1

Arguments

$msg

stringThe message to enqueue.

$type

stringThe message type. Default is message.

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.

getCfg

Gets a configuration value.

getCfg(string $varname, string $default = null) : mixed

An example is in application/japplication-getcfg.php Getting a configuration

since

11.1

Arguments

$varname

stringThe name of the value to get.

$default

stringDefault value to return

Response

mixedThe user state.

getClientId

Gets the client id of the current running application.

getClientId() : integer
since

11.1

Response

integerA client identifier.

getError

Get the most recent error message.

getError(integer $i = null, boolean $toString = true) : string
inherited deprecated
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 deprecated
since

11.1

see \JError
deprecated

12.3 JError has been deprecated

Response

arrayArray of error messages or JErrors.

getHash

Provides a secure hash based on a seed

getHash(string $seed) : string
static
since

11.1

Arguments

$seed

stringSeed string.

Response

stringA secure hash

getInstance

Returns the global JApplication object, only creating it if it doesn't already exist.

getInstance(mixed $client, array $config = array(), string $prefix = 'J') : \JApplication
static
since

11.1

Arguments

$client

mixedA client identifier or name.

$config

arrayAn optional associative array of configuration settings.

$prefix

stringA prefix for class names

Response

\JApplicationA JApplication object.

getMenu

Returns the application JPathway object.

getMenu(string $name = null, array $options = array()) : \JMenu
since

11.1

Arguments

$name

stringThe name of the application/client.

$options

arrayAn optional associative array of configuration settings.

Response

\JMenuJMenu object.

getMessageQueue

Get the system message queue.

getMessageQueue() : array
since

11.1

Response

arrayThe system message queue.

getName

Method to get the application name.

getName() : string

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

since

11.1

Response

stringThe name of the dispatcher.

getPathway

Returns the application JPathway object.

getPathway(string $name = null, array $options = array()) : \JPathway
since

11.1

Arguments

$name

stringThe name of the application.

$options

arrayAn optional associative array of configuration settings.

Response

\JPathwayA JPathway object

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

getRouter

Returns the application JRouter object.

getRouter(string $name = null, array $options = array()) : \JRouter
static
since

11.1

Arguments

$name

stringThe name of the application.

$options

arrayAn optional associative array of configuration settings.

Response

\JRouterA JRouter object

getTemplate

Gets the name of the current template.

getTemplate(array $params = false) : string
since

11.1

Arguments

$params

arrayAn optional associative array of configuration settings

Response

stringSystem is the fallback.

getUserState

Gets a user state.

getUserState(string $key, mixed $default = null) : mixed
since

11.1

Arguments

$key

stringThe path of the state.

$default

mixedOptional default value, returned if the internal value is null.

Response

mixedThe user state or null.

getUserStateFromRequest

Gets the value of a user state variable.

getUserStateFromRequest(string $key, string $request, string $default = null, string $type = 'none') : \The
since

11.1

Arguments

$key

stringThe key of the user state variable.

$request

stringThe name of the variable passed in a request.

$default

stringThe default value for the variable if not found. Optional.

$type

stringFilter for the variable, for valid values see {@link JFilterInput::clean()}. Optional.

Response

\Therequest user state.

initialise

Initialise the application.

initialise(array $options = array()) : void
since

11.1

Arguments

$options

arrayAn optional associative array of configuration settings.

isAdmin

Is admin interface?

isAdmin() : boolean
since

11.1

Response

booleanTrue if this application is administrator.

isSite

Is site interface?

isSite() : boolean
since

11.1

Response

booleanTrue if this application is site.

isWinOS

Method to determine if the host OS is Windows

isWinOS() : boolean
static
since

11.1

Response

booleanTrue if Windows OS

login

Login authentication function.

login(array $credentials, array $options = array()) : boolean

Username and encoded password are passed the onUserLogin event which is responsible for the user validation. A successful validation updates the current session record with the user's details.

Username and encoded password are sent as credentials (along with other possibilities) to each observer (authentication plugin) for user validation. Successful validation will update the current session with the user details.

since

11.1

Arguments

$credentials

arrayArray('username' => string, 'password' => string)

$options

arrayArray('remember' => boolean)

Response

booleanTrue on success.

logout

Logout authentication function.

logout(integer $userid = null, array $options = array()) : boolean

Passed the current user information to the onUserLogout event and reverts the current session record back to 'anonymous' parameters. If any of the authentication plugins did not successfully complete the logout routine then the whole method fails. Any errors raised should be done in the plugin as this provides the ability to give much more information about why the routine may have failed.

since

11.1

Arguments

$userid

integerThe user to load - Can be an integer or string - If string, it is converted to ID automatically

$options

arrayArray('clientid' => array of client id's)

Response

booleanTrue on success

redirect

Redirect to another URL.

redirect(string $url, string $msg = '', string $msgType = 'message', boolean $moved = false) : void

Optionally enqueues a message in the system message queue (which will be displayed the next time a page is loaded) using the enqueueMessage method. If the headers have not been sent the redirect will be accomplished using a "301 Moved Permanently" code in the header pointing to the new location. If the headers have already been sent this will be accomplished using a JavaScript statement.

since

11.1

see \JApplication::enqueueMessage()

Arguments

$url

stringThe URL to redirect to. Can only be http/https URL

$msg

stringAn optional message to display on redirect.

$msgType

stringAn optional message type. Defaults to message.

$moved

booleanTrue if the page is 301 Permanently Moved, otherwise 303 See Other is assumed.

registerEvent

Registers a handler to a particular event group.

registerEvent(string $event, mixed $handler) : void
static
since

11.1

Arguments

$event

stringThe event name.

$handler

mixedThe handler, a function or an instance of a event object.

render

Render the application.

render() : void

Rendering is the process of pushing the document buffers into the template placeholders, retrieving data from the document and pushing it into the JResponse buffer.

since

11.1

route

Route the application.

route() : void

Routing is the process of examining the request environment to determine which component should receive the request. The component optional parameters are then set in the request object to be processed when the application is being dispatched.

since

11.1

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 deprecated
since

11.1

see \JError
deprecated

12.3 JError has been deprecated

Arguments

$error

stringError message.

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

setUserState

Sets the value of a user state variable.

setUserState(string $key, string $value) : mixed
since

11.1

Arguments

$key

stringThe path of the state.

$value

stringThe value of the variable.

Response

mixedThe previous state, if one existed.

stringURLSafe

This method transliterates a string into an URL safe string or returns a URL safe UTF-8 string based on the global configuration

stringURLSafe(string $string) : string
static
since

11.1

Arguments

$string

stringString to process

Response

stringProcessed string

toString

Converts the object to a string (the class name).

toString() : string
inherited deprecated
since

11.1

deprecated

12.1 Use magic method __toString()

see \JObject::__toString()

Response

string

triggerEvent

Calls all handlers associated with an event group.

triggerEvent(string $event, array $args = null) : array
since

11.1

Arguments

$event

stringThe event name.

$args

arrayAn array of arguments.

Response

arrayAn array of results from each function call.

Properties

_clientId

The client identifier.

since

11.1

Type(s)

integer

_messageQueue

The application message queue.

since

11.1

Type(s)

array

_name

The name of the application.

since

11.1

Type(s)

array

scope

The scope of the application.

since

11.1

Type(s)

string

requestTime

The time the request was made.

since

11.1

Type(s)

\date

startTime

The time the request was made as Unix timestamp.

since

11.1

Type(s)

integer

input

The application input object.

since

11.2

Type(s)

\JInput

instances

JApplication instances container.

static
since

11.3

Type(s)

array

_errors

An array of error messages or Exception objects.

inherited deprecated
since

11.1

see \JError
deprecated

12.3 JError has been deprecated

Type(s)

array