WebApplication

Extends AbstractWebApplication

Base class for a Joomla! Web application.

abstract
since

2.5.0

package

Joomla CMS

Methods

__construct

Class constructor.

__construct(\Joomla\CMS\Input\Input input = null, \Joomla\Registry\Registry config = null, \Joomla\Application\Web\WebClient client = null, \Psr\Http\Message\ResponseInterface response = null) : 
since

1.7.3

Arguments

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

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.

client

WebClientAn optional argument to provide dependency injection for the application's client object. If the argument is a WebClient object that object will become the application's client object, otherwise a default client object is created.

response

ResponseInterfaceAn optional argument to provide dependency injection for the application's response object. If the argument is a ResponseInterface object that object will become the application's response object, otherwise a default response object is created.

Response

mixed

afterSessionStart

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

afterSessionStart(\Joomla\Session\SessionEvent event) : 
since

3.0.1

Arguments

event

SessionEventSession event being triggered

Response

void

execute

Execute the application.

execute() : 
since

1.7.3

Response

void

flushAssets

Flush the media version to refresh versionable assets

flushAssets() : 
since

3.2

Response

void

getConfig

Retrieve the application configuration object.

getConfig() : \Joomla\Registry\Registry
since

4.0.0

Response

Registry

getDispatcher

Get the event dispatcher.

getDispatcher() : \Joomla\Event\DispatcherInterface
inherited abstract
since

4.0.0

throws

UnexpectedValueExceptionMay be thrown if the dispatcher has not been set.

Response

DispatcherInterface

getDocument

Method to get the application document object.

getDocument() : \Joomla\CMS\Document\Document
since

1.7.3

Response

DocumentThe document object

getIdentity

Get the application identity.

getIdentity() : \Joomla\CMS\User\User
inherited
since

4.0.0

Response

User

getInstance

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

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

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

since

1.7.3

throws

RuntimeException

deprecated

4.0 will be removed in 6.0 Use the application service in the DI container instead Example: \Joomla\CMS\Factory::getContainer()->get($name)

Arguments

name

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

Response

WebApplication

getLanguage

Method to get the application language object.

getLanguage() : \Joomla\CMS\Language\Language
since

1.7.3

Response

LanguageThe language object

getLogger

Get the logger.

getLogger() : \Psr\Log\LoggerInterface
inherited abstract
since

4.0.0

Response

LoggerInterface

loadDocument

Allows the application to load a custom or default document.

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

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

DocumentAn optional document object. If omitted, the factory document is created.

Response

WebApplicationThis method is chainable.

loadIdentity

Allows the application to load a custom or default identity.

loadIdentity(\Joomla\CMS\User\User identity = null) : 
inherited
since

4.0.0

Arguments

identity

UserAn optional identity object. If omitted, a null user object is created.

Response

$this

loadLanguage

Allows the application to load a custom or default language.

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

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

LanguageAn optional language object. If omitted, the factory language is created.

Response

WebApplicationThis method is chainable.

loadSession

Allows the application to load a custom or default session.

loadSession(\Joomla\CMS\Session\Session session = null) : \Joomla\CMS\Application\WebApplication
deprecated

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

deprecated

4.3 will be removed in 6.0 The session should be injected as a service.

Arguments

session

SessionAn optional session object. If omitted, the session is created.

Response

WebApplicationThis method is chainable.

loadSystemUris

Method to load the system URI strings for the application.

loadSystemUris( requestUri = null) : 
since

1.7.3

Arguments

requestUri

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

Response

void

registerEvent

Registers a handler to a particular event group.

registerEvent( event, 
Warning: Array to string conversion in /opt/phpdoc/vendor/twig/twig/src/Extension/CoreExtension.php on line 768
|Array handler) : 
inherited
since

4.0.0

Arguments

event

stringThe event name.

handler

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

Response

$this

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

1.7.3

Response

void

triggerEvent

Calls all handlers associated with an event group.

triggerEvent( eventName, array|\Joomla\Event\Event args = []) : mixed||string|int
inherited deprecated

This is a legacy method, implementing old-style (Joomla! 3.x) plugin calls. It's best to go directly through the Dispatcher and handle the returned EventInterface object instead of going through this method. This method is deprecated and will be removed in Joomla! 5.x.

This method will only return the 'result' argument of the event

since

4.0.0

throws

InvalidArgumentException

deprecated

4.0 will be removed in 6.0 Use the Dispatcher method instead Example: Factory::getApplication()->getDispatcher()->dispatch($eventName, $event);

Arguments

eventName

stringThe event name.

args

array<string|int, mixed>|EventAn array of arguments or an Event object (optional).

Response

array<string|int, mixed>An array of results from each function call. Note this will be an empty array if no dispatcher is set.

Properties

identity

The application identity object.

inherited
since

4.0.0

Type(s)

User

JComponentTitle

The application component title.

since

4.3.0

Type(s)

string

item_associations

The item associations

deprecated
since

4.3.0

deprecated

4.4.0 will be removed in 6.0 as this property is not used anymore

Type(s)

int

document

The application document object.

since

1.7.3

Type(s)

Document

language

The application language object.

since

1.7.3

Type(s)

Language

instance

The application instance.

static
since

1.7.3

Type(s)

static