WebApplication
Extends \Joomla\CMS\Application\BaseApplicationBase class for a Joomla! Web application.
since |
2.5.0 |
---|---|
note |
As of 4.0 this class will be abstract |
Methods
__construct
Class constructor.
__construct(\Joomla\Input\Input $input = null, \Joomla\Registry\Registry $config = null)
since |
1.0 |
---|
Arguments
- $input
\Joomla\Input\Input
An optional argument to provide dependency injection for the application's input object. If the argument is an Input object that object will become the application's input object, otherwise a default input object is created.- $config
\Joomla\Registry\Registry
An 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.
afterSessionStart
After the session has been started we need to populate it with some default values.
afterSessionStart() : void
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(boolean $allow = null) : boolean
since |
1.7.3 |
---|
Arguments
- $allow
boolean
True to allow browser caching.
Response
boolean
appendBody
Append content to the body content
appendBody(string $content) : \Joomla\CMS\Application\WebApplication
since |
1.7.3 |
---|
Arguments
- $content
string
The content to append to the response body.
Response
\Joomla\CMS\Application\WebApplication
Instance 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() : boolean
see | \Joomla\CMS\Application\connection_status() |
---|---|
since |
1.7.3 |
Response
boolean
True 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() : boolean
see | \Joomla\CMS\Application\headers_sent() |
---|---|
since |
1.7.3 |
Response
boolean
True if the headers have already been sent.
clearHeaders
Method to clear any set response headers.
clearHeaders() : \Joomla\CMS\Application\WebApplication
close
Method to close the application.
close(integer $code) : void
since |
1.0 |
---|
Arguments
- $code
integer
The exit code (optional; default is 0).
compress
Checks the accept encoding of the browser and compresses the data before sending it to the client if possible.
compress() : void
since |
1.7.3 |
---|
detectRequestUri
Method to detect the requested URI from server environment variables.
detectRequestUri() : string
since |
1.7.3 |
---|
Response
string
The 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() : mixed
since |
1.0 |
---|
Response
mixed
execute
Execute the application.
execute() : void
since |
1.0 |
---|
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
since |
1.7.3 |
---|---|
throws |
|
Arguments
- $file
string
The path and filename of the configuration file. If not provided, configuration.php in JPATH_CONFIGURATION will be used.- $class
string
The class name to instantiate.
Response
mixed
Either an array or object to be loaded into the configuration object.
flushAssets
Flush the media version to refresh versionable assets
flushAssets() : void
since |
3.2 |
---|
get
Returns a property of the object or the default value if the property is not set.
get(string $key, mixed $default = null) : mixed
since |
1.0 |
---|
Arguments
- $key
string
The name of the property.- $default
mixed
The default value (optional) if none is set.
Response
mixed
The value of the configuration.
getBody
Return the body content
getBody(boolean $asArray = false) : mixed
since |
1.7.3 |
---|
Arguments
- $asArray
boolean
True to return the body as an array of strings.
Response
mixed
The response body either as an array or concatenated string.
getDocument
Method to get the application document object.
getDocument() : \JDocument
since |
1.7.3 |
---|
Response
\JDocument
The document object
getHeaders
Method to get the array of response headers to be sent when the response is sent to the client.
getHeaders() : array
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
since |
3.8.0 |
---|
Arguments
- $value
string
The given status as int or string
Response
string
getIdentity
Get the application identity.
getIdentity() : mixed
since |
3.0.0 |
---|
Response
mixed
A \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
This method must be invoked as: $web = WebApplication::getInstance();
since |
1.7.3 |
---|
Arguments
- $name
string
The name (optional) of the JApplicationWeb class to instantiate.
Response
getLanguage
Method to get the application language object.
getLanguage() : \JLanguage
since |
1.7.3 |
---|
Response
\JLanguage
The language object
getLogger
Get the logger.
getLogger() : \Psr\Log\LoggerInterface
since |
1.0 |
---|
Response
\Psr\Log\LoggerInterface
getSession
Method to get the application session object.
getSession() : \JSession
since |
1.7.3 |
---|
Response
\JSession
The session object
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, boolean $replace = true, integer $code = null) : void
see | \Joomla\CMS\Application\WebApplication::header() |
---|---|
since |
1.7.3 |
Arguments
- $string
string
The header string.- $replace
boolean
The optional replace parameter indicates whether the header should replace a previous similar header, or add a second header of the same type.- $code
integer
Forces the HTTP response code to the specified value. Note that this parameter only has an effect if the string is not empty.
initialise
Custom initialisation method.
initialise() : void
Called at the end of the AbstractApplication::__construct method. This is for developers to inject initialisation code for their application classes.
since |
1.0 |
---|
isRedirectState
Checks if a state is a redirect state
isRedirectState(integer $state) : boolean
since |
3.8.0 |
---|
Arguments
- $state
integer
The HTTP 1.1 status code.
Response
boolean
isSSLConnection
Determine if we are using a secure (SSL) connection.
isSSLConnection() : boolean
since |
3.0.1 |
---|
Response
boolean
True if using SSL, false if not.
loadConfiguration
Load an object or array into the application configuration object.
loadConfiguration(mixed $data) : \Joomla\CMS\Application\WebApplication
since |
1.7.3 |
---|
Arguments
- $data
mixed
Either an array or object to be loaded into the configuration object.
Response
\Joomla\CMS\Application\WebApplication
Instance of $this to allow chaining.
loadDispatcher
Allows the application to load a custom or default dispatcher.
loadDispatcher(\JEventDispatcher $dispatcher = null) : \Joomla\CMS\Application\BaseApplication
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
\JEventDispatcher
An optional dispatcher object. If omitted, the factory dispatcher is created.
Response
\Joomla\CMS\Application\BaseApplication
This method is chainable.
loadDocument
Allows the application to load a custom or default document.
loadDocument(\JDocument $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
\JDocument
An optional document object. If omitted, the factory document is created.
Response
\Joomla\CMS\Application\WebApplication
This method is chainable.
loadIdentity
Allows the application to load a custom or default identity.
loadIdentity(\JUser $identity = null) : \Joomla\CMS\Application\BaseApplication
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
\JUser
An optional identity object. If omitted, the factory user is created.
Response
\Joomla\CMS\Application\BaseApplication
This method is chainable.
loadLanguage
Allows the application to load a custom or default language.
loadLanguage(\JLanguage $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
\JLanguage
An optional language object. If omitted, the factory language is created.
Response
\Joomla\CMS\Application\WebApplication
This method is chainable.
loadSession
Allows the application to load a custom or default session.
loadSession(\JSession $session = 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 session, if required, based on more specific needs.
since |
1.7.3 |
---|
Arguments
- $session
\JSession
An optional session object. If omitted, the session is created.
Response
\Joomla\CMS\Application\WebApplication
This 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
string
An optional request URI to use instead of detecting one from the server environment variables.
prependBody
Prepend content to the body content
prependBody(string $content) : \Joomla\CMS\Application\WebApplication
since |
1.7.3 |
---|
Arguments
- $content
string
The content to prepend to the response body.
Response
\Joomla\CMS\Application\WebApplication
Instance of $this to allow chaining.
redirect
Redirect to another URL.
redirect(string $url, integer $status = 303) : void
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
string
The URL to redirect to. Can only be http/https URL.- $status
integer
The 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
since |
3.0.0 |
---|
Arguments
- $event
string
The event name.- $handler
callable
The handler, a function or an instance of an event object.
Response
\Joomla\CMS\Application\BaseApplication
The 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
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
since |
1.7.3 |
---|
sendHeaders
Send the response headers.
sendHeaders() : \Joomla\CMS\Application\WebApplication
set
Modifies a property of the object, creating it if it does not already exist.
set(string $key, mixed $value = null) : mixed
since |
1.0 |
---|
Arguments
- $key
string
The name of the property.- $value
mixed
The value of the property to set (optional).
Response
mixed
Previous value of the property
setBody
Set body content. If body content already defined, this will replace it.
setBody(string $content) : \Joomla\CMS\Application\WebApplication
since |
1.7.3 |
---|
Arguments
- $content
string
The content to set as the response body.
Response
\Joomla\CMS\Application\WebApplication
Instance of $this to allow chaining.
setConfiguration
Sets the configuration for the application.
setConfiguration(\Joomla\Registry\Registry $config) : \Joomla\Application\AbstractApplication
since |
1.0 |
---|
Arguments
- $config
\Joomla\Registry\Registry
A registry object holding the configuration.
Response
\Joomla\Application\AbstractApplication
Returns itself to support 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, boolean $replace = false) : \Joomla\CMS\Application\WebApplication
since |
1.7.3 |
---|
Arguments
- $name
string
The name of the header to set.- $value
string
The value of the header to set.- $replace
boolean
True to replace any headers with the same name.
Response
\Joomla\CMS\Application\WebApplication
Instance of $this to allow chaining.
setLogger
Set the logger.
setLogger(\Psr\Log\LoggerInterface $logger) : \Joomla\Application\AbstractApplication
since |
1.0 |
---|
Arguments
- $logger
\Psr\Log\LoggerInterface
The logger.
Response
\Joomla\Application\AbstractApplication
Returns itself to support chaining.
triggerEvent
Calls all handlers associated with an event group.
triggerEvent(string $event, array $args = null) : array
since |
3.0.0 |
---|
Arguments
- $event
string
The event name.- $args
array
An array of arguments (optional).
Response
array
An array of results from each function call, or null if no dispatcher is defined.
Properties
charSet
Character encoding string.
since |
1.7.3 |
---|
Type(s)
string
mimeType
Response mime type.
since |
1.7.3 |
---|
Type(s)
string
modifiedDate
The body modified date for response headers.
since |
1.7.3 |
---|
Type(s)
\JDate
client
The application client object.
since |
1.7.3 |
---|
Type(s)
\JApplicationWebClient
document
The application document object.
since |
1.7.3 |
---|
Type(s)
\JDocument
language
The application language object.
since |
1.7.3 |
---|
Type(s)
\JLanguage
session
The application session object.
since |
1.7.3 |
---|
Type(s)
\JSession
response
The application response object.
since |
1.7.3 |
---|
Type(s)
object
instance
The application instance.
responseMap
A map of integer HTTP 1.1 response codes to the full HTTP Status for the headers.
singleValueResponseHeaders
A map of HTTP Response headers which may only send a single value, all others are considered to allow multiple
identity
The application identity object.
since |
3.0.0 |
---|
Type(s)
\JUser
logger
A logger.
since |
1.0 |
---|
Type(s)
\Psr\Log\LoggerInterface
input
The application input object.
The application input object
Type(s)
\JInput