CMSApplication

Extends WebApplication

Joomla! CMS Application class

since

3.2

package

Joomla CMS

Methods

__construct

Class constructor.

__construct(\Joomla\CMS\Input\Input input = null, \Joomla\Registry\Registry config = null) : mixed
inherited
since

3.0.0

Arguments

input

\Joomla\CMS\Input\InputAn optional argument to provide dependency injection for the application's input object. If the argument is a \JInput object that object will become the application's input object, otherwise a default input object is created.

config

\Joomla\Registry\RegistryAn optional argument to provide dependency injection for the application's config object. If the argument is a Registry object that object will become the application's config object, otherwise a default config object is created.

Response

mixed

afterSessionStart

After the session has been started we need to populate it with some default values.

afterSessionStart() : void
inherited
since

3.0.1

allowCache

Set/get cachable state for the response. If $allow is set, sets the cachable state of the response. Always returns the current state.

allowCache(bool allow = null) : bool
inherited
since

1.7.3

Arguments

allow

boolTrue to allow browser caching.

Response

bool

appendBody

Append content to the body content

appendBody(string content) : \Joomla\CMS\Application\WebApplication
inherited
since

1.7.3

Arguments

content

stringThe content to append to the response body.

Response

\Joomla\CMS\Application\WebApplicationInstance of $this to allow chaining.

checkConnectionAlive

Method to check the current client connection status to ensure that it is alive. We are wrapping this to isolate the connection_status() function from our code base for testing reasons.

checkConnectionAlive() : bool
inherited
see connection_status()
since

1.7.3

Response

boolTrue if the connection is valid and normal.

checkHeadersSent

Method to check to see if headers have already been sent. We are wrapping this to isolate the headers_sent() function from our code base for testing reasons.

checkHeadersSent() : bool
inherited
see headers_sent()
since

1.7.3

Response

boolTrue if the headers have already been sent.

checkSession

Checks the user session.

checkSession() : void

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

since

3.2

throws

\RuntimeException

checkUserRequireReset

Check if the user is required to reset their password.

checkUserRequireReset(string option, string view, string layout, string tasks) : void

If the user is required to reset their password will be redirected to the page that manage the password reset.

Arguments

option

stringThe option that manage the password reset

view

stringThe view that manage the password reset

layout

stringThe layout of the view that manage the password reset

tasks

stringPermitted tasks

clearHeaders

Method to clear any set response headers.

clearHeaders() : \Joomla\CMS\Application\WebApplication
inherited
since

1.7.3

Response

\Joomla\CMS\Application\WebApplicationInstance of $this to allow chaining.

compress

Checks the accept encoding of the browser and compresses the data before sending it to the client if possible.

compress() : void
inherited
since

1.7.3

detectRequestUri

Method to detect the requested URI from server environment variables.

detectRequestUri() : string
inherited
since

1.7.3

Response

stringThe requested URI

doExecute

Method to run the application routines. Most likely you will want to instantiate a controller and execute it, or perform some sort of task directly.

doExecute() : void
inherited deprecated
since

3.4

deprecated

4.0 The default concrete implementation of doExecute() will be removed, subclasses will need to provide their own implementation.

enqueueMessage

Enqueue a system message.

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

3.2

Arguments

msg

stringThe message to enqueue.

type

stringThe message type. Default is message.

execute

Execute the application.

execute() : void
inherited
since

1.7.3

fetchConfigurationData

Method to load a PHP configuration class file based on convention and return the instantiated data object. You will extend this method in child classes to provide configuration data from whatever data source is relevant for your specific application.

fetchConfigurationData(string file = '', string class = '\JConfig') : mixed
inherited
since

1.7.3

throws

\RuntimeException

Arguments

file

stringThe path and filename of the configuration file. If not provided, configuration.php in JPATH_CONFIGURATION will be used.

class

stringThe class name to instantiate.

Response

mixedEither an array or object to be loaded into the configuration object.

flushAssets

Flush the media version to refresh versionable assets

flushAssets() : void
inherited
since

3.2

getBody

Return the body content

getBody(bool asArray = false) : mixed
inherited
since

1.7.3

Arguments

asArray

boolTrue to return the body as an array of strings.

Response

mixedThe response body either as an array or concatenated string.

getCfg

Gets a configuration value.

getCfg(string varname, string default = null) : mixed
deprecated
since

3.2

deprecated

5.0 Use get() instead

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() : int
since

3.2

Response

intA client identifier.

getDocument

Method to get the application document object.

getDocument() : \JDocument
inherited
since

1.7.3

Response

\JDocumentThe document object

getHeaders

Method to get the array of response headers to be sent when the response is sent to the client.

getHeaders() : array
inherited
since

1.7.3

Response

array*

getHttpStatusValue

Check if a given value can be successfully mapped to a valid http status value

getHttpStatusValue(string value) : string
inherited
since

3.8.0

Arguments

value

stringThe given status as int or string

Response

string

getIdentity

Get the application identity.

getIdentity() : mixed
inherited
since

3.0.0

Response

mixedA \JUser object or null.

getInstance

Returns a reference to the global WebApplication object, only creating it if it doesn't already exist.

getInstance(string name = null) : \Joomla\CMS\Application\WebApplication
inherited static

This method must be invoked as: $web = WebApplication::getInstance();

since

1.7.3

Arguments

name

stringThe name (optional) of the JApplicationWeb class to instantiate.

Response

\Joomla\CMS\Application\WebApplication

getLanguage

Method to get the application language object.

getLanguage() : \JLanguage
inherited
since

1.7.3

Response

\JLanguageThe language object

getMenu

Returns the application \JMenu object.

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

3.2

Arguments

name

stringThe name of the application/client.

options

arrayAn optional associative array of configuration settings.

Response

\JMenu|null

getMessageQueue

Get the system message queue.

getMessageQueue(bool clear = false) : array
since

3.2

Arguments

clear

boolClear the messages currently attached to the application object

Response

arrayThe system message queue.

getName

Gets the name of the current running application.

getName() : string
since

3.2

Response

stringThe name of the application.

getPathway

Returns the application \JPathway object.

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

3.2

Arguments

name

stringThe name of the application.

options

arrayAn optional associative array of configuration settings.

Response

\JPathway|null

getRouter

Returns the application \JRouter object.

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

3.2

Arguments

name

stringThe name of the application.

options

arrayAn optional associative array of configuration settings.

Response

\JRouter|null

getSession

Method to get the application session object.

getSession() : \JSession
inherited
since

1.7.3

Response

\JSessionThe session object

getTemplate

Gets the name of the current template.

getTemplate(bool params = false) : mixed
since

3.2

Arguments

params

boolAn optional associative array of configuration settings

Response

mixedSystem is the fallback.

getUserState

Gets a user state.

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

3.2

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') : mixed
since

3.2

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

mixedThe request user state.

header

Method to send a header to the client. We are wrapping this to isolate the header() function from our code base for testing reasons.

header(string string, bool replace = true, int code = null) : void
inherited
see header()
since

1.7.3

Arguments

string

stringThe header string.

replace

boolThe optional replace parameter indicates whether the header should replace a previous similar header, or add a second header of the same type.

code

intForces the HTTP response code to the specified value. Note that this parameter only has an effect if the string is not empty.

initialise

Initialise the application.

initialise(mixed session = null, mixed document = null, mixed language = null, mixed dispatcher = null) : \Joomla\CMS\Application\WebApplication
inherited deprecated
deprecated

4.0

see WebApplication::loadSession() WebApplication::loadDocument() WebApplication::loadLanguage() WebApplication::loadDispatcher()
since

1.7.3

Arguments

session

mixedAn optional argument to provide dependency injection for the application's session object. If the argument is a \JSession object that object will become the application's session object, if it is false then there will be no session object, and if it is null then the default session object will be created based on the application's loadSession() method.

document

mixedAn optional argument to provide dependency injection for the application's document object. If the argument is a \JDocument object that object will become the application's document object, if it is false then there will be no document object, and if it is null then the default document object will be created based on the application's loadDocument() method.

language

mixedAn optional argument to provide dependency injection for the application's language object. If the argument is a \JLanguage object that object will become the application's language object, if it is false then there will be no language object, and if it is null then the default language object will be created based on the application's loadLanguage() method.

dispatcher

mixedAn optional argument to provide dependency injection for the application's event dispatcher. If the argument is a \JEventDispatcher object that object will become the application's event dispatcher, if it is null then the default event dispatcher will be created based on the application's loadDispatcher() method.

Response

\Joomla\CMS\Application\WebApplicationInstance of $this to allow chaining.

initialiseApp

Initialise the application.

initialiseApp(array options = array()) : void
since

3.2

Arguments

options

arrayAn optional associative array of configuration settings.

isAdmin

Is admin interface?

isAdmin() : bool
deprecated
since

3.2

deprecated

4.0 Use isClient('administrator') instead.

Response

boolTrue if this application is administrator.

isClient

Check the client interface by name.

isClient(string identifier) : bool
since

3.7.0

Arguments

identifier

stringString identifier for the application interface

Response

boolTrue if this application is of the given type client interface.

isHttpsForced

Checks if HTTPS is forced in the client configuration.

isHttpsForced(int clientId = null) : bool
since

3.7.3

Arguments

clientId

intAn optional client id (defaults to current application client).

Response

boolTrue if is forced for the client, false otherwise.

isRedirectState

Checks if a state is a redirect state

isRedirectState(int state) : bool
inherited
since

3.8.0

Arguments

state

intThe HTTP 1.1 status code.

Response

bool

isSite

Is site interface?

isSite() : bool
deprecated
since

3.2

deprecated

4.0 Use isClient('site') instead.

Response

boolTrue if this application is site.

isSSLConnection

Determine if we are using a secure (SSL) connection.

isSSLConnection() : bool
inherited
since

3.0.1

Response

boolTrue if using SSL, false if not.

loadConfiguration

Load an object or array into the application configuration object.

loadConfiguration(mixed data) : \Joomla\CMS\Application\WebApplication
inherited
since

1.7.3

Arguments

data

mixedEither an array or object to be loaded into the configuration object.

Response

\Joomla\CMS\Application\WebApplicationInstance of $this to allow chaining.

loadDispatcher

Allows the application to load a custom or default dispatcher.

loadDispatcher(\JEventDispatcher dispatcher = null) : \Joomla\CMS\Application\BaseApplication
inherited

The logic and options for creating this object are adequately generic for default cases but for many applications it will make sense to override this method and create event dispatchers, if required, based on more specific needs.

since

3.0.0

Arguments

dispatcher

\JEventDispatcherAn optional dispatcher object. If omitted, the factory dispatcher is created.

Response

\Joomla\CMS\Application\BaseApplicationThis method is chainable.

loadDocument

Allows the application to load a custom or default document.

loadDocument(\JDocument document = null) : \Joomla\CMS\Application\WebApplication
inherited

The logic and options for creating this object are adequately generic for default cases but for many applications it will make sense to override this method and create a document, if required, based on more specific needs.

since

1.7.3

Arguments

document

\JDocumentAn optional document object. If omitted, the factory document is created.

Response

\Joomla\CMS\Application\WebApplicationThis method is chainable.

loadIdentity

Allows the application to load a custom or default identity.

loadIdentity(\JUser identity = null) : \Joomla\CMS\Application\BaseApplication
inherited

The logic and options for creating this object are adequately generic for default cases but for many applications it will make sense to override this method and create an identity, if required, based on more specific needs.

since

3.0.0

Arguments

identity

\JUserAn optional identity object. If omitted, the factory user is created.

Response

\Joomla\CMS\Application\BaseApplicationThis method is chainable.

loadLanguage

Allows the application to load a custom or default language.

loadLanguage(\JLanguage language = null) : \Joomla\CMS\Application\WebApplication
inherited

The logic and options for creating this object are adequately generic for default cases but for many applications it will make sense to override this method and create a language, if required, based on more specific needs.

since

1.7.3

Arguments

language

\JLanguageAn optional language object. If omitted, the factory language is created.

Response

\Joomla\CMS\Application\WebApplicationThis method is chainable.

loadLibraryLanguage

Load the library language files for the application

loadLibraryLanguage() : void
since

3.6.3

loadSession

Allows the application to load a custom or default session.

loadSession(\JSession session = null) : \Joomla\CMS\Application\WebApplication
inherited

The logic and options for creating this object are adequately generic for default cases but for many applications it will make sense to override this method and create a session, if required, based on more specific needs.

since

1.7.3

Arguments

session

\JSessionAn optional session object. If omitted, the session is created.

Response

\Joomla\CMS\Application\WebApplicationThis method is chainable.

loadSystemUris

Method to load the system URI strings for the application.

loadSystemUris(string requestUri = null) : void
inherited
since

1.7.3

Arguments

requestUri

stringAn optional request URI to use instead of detecting one from the server environment variables.

login

Login authentication function.

login(array credentials, array options = array()) : bool|\JException

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

3.2

Arguments

credentials

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

options

arrayArray('remember' => boolean)

Response

bool|\JExceptionTrue on success, false if failed or silent handling is configured, or a \JException object on authentication error.

logout

Logout authentication function.

logout(int userid = null, array options = array()) : bool

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

3.2

Arguments

userid

intThe 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

boolTrue on success

prependBody

Prepend content to the body content

prependBody(string content) : \Joomla\CMS\Application\WebApplication
inherited
since

1.7.3

Arguments

content

stringThe content to prepend to the response body.

Response

\Joomla\CMS\Application\WebApplicationInstance of $this to allow chaining.

redirect

Redirect to another URL.

redirect(string url, int status = 303) : void
inherited

If the headers have not been sent the redirect will be accomplished using a "301 Moved Permanently" or "303 See Other" 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

1.7.3

Arguments

url

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

status

intThe HTTP 1.1 status code to be provided. 303 is assumed by default.

registerEvent

Registers a handler to a particular event group.

registerEvent(string event, callable handler) : \Joomla\CMS\Application\BaseApplication
inherited
since

3.0.0

Arguments

event

stringThe event name.

handler

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

Response

\Joomla\CMS\Application\BaseApplicationThe application to allow chaining.

render

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

render() : void
inherited
since

1.7.3

respond

Method to send the application response to the client. All headers will be sent prior to the main application output data.

respond() : void
inherited
since

1.7.3

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

3.2

sendHeaders

Send the response headers.

sendHeaders() : \Joomla\CMS\Application\WebApplication
inherited
since

1.7.3

Response

\Joomla\CMS\Application\WebApplicationInstance of $this to allow chaining.

setBody

Set body content. If body content already defined, this will replace it.

setBody(string content) : \Joomla\CMS\Application\WebApplication
inherited
since

1.7.3

Arguments

content

stringThe content to set as the response body.

Response

\Joomla\CMS\Application\WebApplicationInstance of $this to allow chaining.

setHeader

Method to set a response header. If the replace flag is set then all headers with the given name will be replaced by the new one. The headers are stored in an internal array to be sent when the site is sent to the browser.

setHeader(string name, string value, bool replace = false) : \Joomla\CMS\Application\WebApplication
inherited
since

1.7.3

Arguments

name

stringThe name of the header to set.

value

stringThe value of the header to set.

replace

boolTrue to replace any headers with the same name.

Response

\Joomla\CMS\Application\WebApplicationInstance of $this to allow chaining.

setUserState

Sets the value of a user state variable.

setUserState(string key, mixed value) : mixed
since

3.2

Arguments

key

stringThe path of the state.

value

mixedThe value of the variable.

Response

mixedThe previous state, if one existed.

toString

Sends all headers prior to returning the string

toString(bool compress = false) : string
since

3.2

Arguments

compress

boolIf true, compress the data

Response

string

triggerEvent

Calls all handlers associated with an event group.

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

3.0.0

Arguments

event

stringThe event name.

args

arrayAn array of arguments (optional).

Response

arrayAn array of results from each function call, or null if no dispatcher is defined.

Properties

docOptions

Array of options for the \JDocument object

since

3.2

Type(s)

array

instances

Application instances container.

static
since

3.2

Type(s)

\Joomla\CMS\Application\CMSApplication[]

scope

The scope of the application.

since

3.2

Type(s)

string

_clientId

The client identifier.

deprecated
since

3.2

deprecated

4.0 Will be renamed $clientId

Type(s)

int

_messageQueue

The application message queue.

deprecated
since

3.2

deprecated

4.0 Will be renamed $messageQueue

Type(s)

array

_name

The name of the application.

deprecated
since

3.2

deprecated

4.0 Will be renamed $name

Type(s)

array

profiler

The profiler instance

since

3.2

Type(s)

\JProfiler

template

Currently active template

since

3.2

Type(s)

object

charSet

Character encoding string.

inherited
since

1.7.3

Type(s)

string

mimeType

Response mime type.

inherited
since

1.7.3

Type(s)

string

modifiedDate

The body modified date for response headers.

inherited
since

1.7.3

Type(s)

\JDate

client

The application client object.

inherited
since

1.7.3

Type(s)

\JApplicationWebClient

document

The application document object.

inherited
since

1.7.3

Type(s)

\JDocument

language

The application language object.

inherited
since

1.7.3

Type(s)

\JLanguage

session

The application session object.

inherited
since

1.7.3

Type(s)

\JSession

response

The application response object.

inherited
since

1.7.3

Type(s)

object

instance

The application instance.

inherited static
since

1.7.3

Type(s)

\Joomla\CMS\Application\WebApplication

responseMap

A map of integer HTTP 1.1 response codes to the full HTTP Status for the headers.

inherited
since

3.4

link

Type(s)

object

singleValueResponseHeaders

A map of HTTP Response headers which may only send a single value, all others are considered to allow multiple

inherited
since

3.5.2

link

Type(s)

object

dispatcher

The application dispatcher object.

inherited
since

3.0.0

Type(s)

\JEventDispatcher

identity

The application identity object.

inherited
since

3.0.0

Type(s)

\JUser

input

inherited

The application input object

Type(s)

\JInput