WebApplication

Extends \Joomla\Application\AbstractWebApplication

Base class for a Joomla! Web application.

abstract
since

2.5.0

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

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

$client

\Joomla\Application\Web\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

\Psr\Http\Message\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.

afterSessionStart

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

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

3.0.1

Arguments

$event

\Joomla\Session\SessionEventSession event being triggered

execute

Execute the application.

execute() : void
since

1.7.3

flushAssets

Flush the media version to refresh versionable assets

flushAssets() : void
since

3.2

getConfig

Retrieve the application configuration object.

getConfig() : \Joomla\Registry\Registry
since

4.0.0

Response

\Joomla\Registry\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

\Joomla\Event\DispatcherInterface

getDocument

Method to get the application document object.

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

1.7.3

Response

\Joomla\CMS\Document\DocumentThe document object

getIdentity

Get the application identity.

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

4.0.0

Response

\Joomla\CMS\User\User

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

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

since

1.7.3

throws

\RuntimeException

deprecated

5.0 Use \Joomla\CMS\Factory::getContainer()->get($name) instead

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() : \Joomla\CMS\Language\Language
since

1.7.3

Response

\Joomla\CMS\Language\LanguageThe language object

getLogger

Get the logger.

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

4.0.0

Response

\Psr\Log\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

\Joomla\CMS\Document\DocumentAn 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(\Joomla\CMS\User\User $identity = null) : $this
inherited
since

4.0.0

Arguments

$identity

\Joomla\CMS\User\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

\Joomla\CMS\Language\LanguageAn optional language object. If omitted, the factory language is created.

Response

\Joomla\CMS\Application\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

5.0 The session should be injected as a service.

Arguments

$session

\Joomla\CMS\Session\SessionAn 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
since

1.7.3

Arguments

$requestUri

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

registerEvent

Registers a handler to a particular event group.

registerEvent(string $event, callable $handler) : $this
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() : void
since

1.7.3

setUserFactory

Set the user factory to use.

setUserFactory(\Joomla\CMS\User\UserFactoryInterface $userFactory) : void
inherited
since

4.0.0

Arguments

$userFactory

\Joomla\CMS\User\UserFactoryInterfaceThe user factory to use

triggerEvent

Calls all handlers associated with an event group.

triggerEvent(string $eventName, array|\Joomla\Event\Event $args = array()) : array
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

5.0

Arguments

$eventName

stringThe event name.

$args

array|\Joomla\Event\EventAn array of arguments or an Event object (optional).

Response

arrayAn array of results from each function call. Note this will be an empty array if no dispatcher is set.

Properties

document

The application document object.

since

1.7.3

Type(s)

\Joomla\CMS\Document\Document

language

The application language object.

since

1.7.3

Type(s)

\Joomla\CMS\Language\Language

instance

The application instance.

static
since

1.7.3

Type(s)

static

identity

The application identity object.

inherited
since

4.0.0

Type(s)

\Joomla\CMS\User\User

userFactory

UserFactoryInterface

inherited