WebApplication
Extends AbstractWebApplication Implements SessionAwareWebApplicationInterfaceA basic web application class for handing HTTP requests.
since |
2.0.0 |
---|---|
package |
Joomla Framework |
Methods
__construct
Class constructor.
__construct(\Joomla\Registry\Registry|null config = null) : mixed
since |
1.0.0 |
---|
Arguments
- config
\Joomla\Registry\Registry|null
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.
Response
mixed
__get
Magic method to access properties of the application.
__get(string name) : \Joomla\Input\Input|null
since |
2.0.0 |
---|---|
deprecated |
3.0 This is a B/C proxy for deprecated read accesses |
Arguments
- name
string
The name of the property.
Response
\Joomla\Input\Input|null
A value if the property name is valid, null otherwise.
allowCache
Set/get cachable state for the response.
allowCache(bool allow = null) : bool
If $allow is set, sets the cachable state of the response. Always returns the current state.
since |
1.0.0 |
---|
Arguments
- allow
bool
True to allow browser caching.
Response
bool
appendBody
Append content to the body content
appendBody(string content) : $this
since |
1.0.0 |
---|
Arguments
- content
string
The content to append to the response body.
Response
$this
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
see | connection_status() |
---|---|
since |
1.0.0 |
Response
bool
True if the connection is valid and normal.
checkHeadersSent
Method to check to see if headers have already been sent.
checkHeadersSent() : bool
see | headers_sent() |
---|---|
since |
1.0.0 |
Response
bool
True if the headers have already been sent.
checkToken
Checks for a form token in the request.
checkToken(string method = 'post') : bool
since |
2.0.0 |
---|
Arguments
- method
string
The request method in which to look for the token key.
Response
bool
clearHeaders
Method to clear any set response headers.
clearHeaders() : $this
since |
1.0.0 |
---|
Response
$this
close
Method to close the application.
close(int code) : void
since |
1.0.0 |
---|
Arguments
- code
int
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.0.0 |
---|
detectRequestUri
Method to detect the requested URI from server environment variables.
detectRequestUri() : string
since |
1.0.0 |
---|
Response
string
The requested URI
dispatchEvent
Dispatches an application event if the dispatcher has been set.
dispatchEvent(string eventName, \Joomla\Event\EventInterface|null event = null) : \Joomla\Event\EventInterface|null
since |
2.0.0 |
---|
Arguments
- eventName
string
The event to dispatch.- event
\Joomla\Event\EventInterface|null
The event object.
Response
\Joomla\Event\EventInterface|null
The dispatched event or null if no dispatcher is set
doExecute
Method to run the application routines.
doExecute() : mixed
Most likely you will want to instantiate a controller and execute it, or perform some sort of task directly.
since |
1.0.0 |
---|
Response
mixed
execute
Execute the application.
execute() : void
since |
1.0.0 |
---|
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.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() : string
since |
1.0.0 |
---|
Response
string
The response body as a string.
getDispatcher
Get the event dispatcher.
getDispatcher() : \Joomla\Event\DispatcherInterface
since |
1.2.0 |
---|---|
throws |
|
Response
\Joomla\Event\DispatcherInterface
getFormToken
Method to determine a hash for anti-spoofing variable names
getFormToken(bool forceNew = false) : string
since |
2.0.0 |
---|
Arguments
- forceNew
bool
If true, force a new token to be created
Response
string
Hashed var name
getHeaders
Method to get the array of response headers to be sent when the response is sent to the client.
getHeaders() : array
since |
1.0.0 |
---|
Response
array
getHttpStatusValue
Check if a given value can be successfully mapped to a valid http status value
getHttpStatusValue(string|int value) : string
since |
1.8.0 |
---|
Arguments
- value
string|int
The given status as int or string
Response
string
getInput
Method to get the application input object.
getInput() : \Joomla\Input\Input
since |
2.0.0 |
---|
Response
\Joomla\Input\Input
getLogger
Get the logger.
getLogger() : \Psr\Log\LoggerInterface
since |
1.0.0 |
---|
Response
\Psr\Log\LoggerInterface
getResponse
Get the PSR-7 Response Object.
getResponse() : \Psr\Http\Message\ResponseInterface
since |
2.0.0 |
---|
Response
\Psr\Http\Message\ResponseInterface
getSession
Method to get the application session object.
getSession() : \Joomla\Session\SessionInterface
since |
2.0.0 |
---|
Response
\Joomla\Session\SessionInterface
The session object
header
Method to send a header to the client.
header(string string, bool replace = true, int code = null) : void
see | header() |
---|---|
since |
1.0.0 |
Arguments
- string
string
The header string.- replace
bool
The optional replace parameter indicates whether the header should replace a previous similar header, or add a second header of the same type.- code
int
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.0 |
---|
isAscii
Tests whether a string contains only 7bit ASCII bytes.
isAscii(string str) : bool
You might use this to conditionally check whether a string needs handling as UTF-8 or not, potentially offering performance benefits by using the native PHP equivalent if it's just ASCII e.g.;
since |
1.4.0 |
---|
Arguments
- str
string
The string to test.
Response
bool
True if the string is all ASCII
isRedirectState
Checks if a state is a redirect state
isRedirectState(int state) : bool
since |
1.8.0 |
---|
Arguments
- state
int
The HTTP status code.
Response
bool
isSslConnection
Determine if we are using a secure (SSL) connection.
isSslConnection() : bool
since |
1.0.0 |
---|
Response
bool
True if using SSL, false if not.
isValidHttpStatus
Check if the value is a valid HTTP status code
isValidHttpStatus(int code) : bool
since |
1.8.1 |
---|
Arguments
- code
int
The potential status code
Response
bool
loadSystemUris
Method to load the system URI strings for the application.
loadSystemUris(string requestUri = null) : void
since |
1.0.0 |
---|
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) : $this
since |
1.0.0 |
---|
Arguments
- content
string
The content to prepend to the response body.
Response
$this
redirect
Redirect to another URL.
redirect(string url, int|bool 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.
throws |
|
---|---|
since |
1.0.0 |
Arguments
- url
string
The URL to redirect to. Can only be http/https URL- status
int|bool
The HTTP status code to be provided. 303 is assumed by default.
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.0.0 |
---|
sendHeaders
Send the response headers.
sendHeaders() : $this
since |
1.0.0 |
---|
Response
$this
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.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) : $this
since |
1.0.0 |
---|
Arguments
- content
string
The content to set as the response body.
Response
$this
setConfiguration
Sets the configuration for the application.
setConfiguration(\Joomla\Registry\Registry config) : $this
since |
1.0.0 |
---|
Arguments
- config
\Joomla\Registry\Registry
A registry object holding the configuration.
Response
$this
setDispatcher
Set the dispatcher to use.
setDispatcher(\Joomla\Event\DispatcherInterface dispatcher) : $this
since |
1.2.0 |
---|
Arguments
- dispatcher
\Joomla\Event\DispatcherInterface
The dispatcher to use.
Response
$this
setHeader
Method to set a response header.
setHeader(string name, string value, bool replace = false) : $this
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.
since |
1.0.0 |
---|
Arguments
- name
string
The name of the header to set.- value
string
The value of the header to set.- replace
bool
True to replace any headers with the same name.
Response
$this
setResponse
Set the PSR-7 Response Object.
setResponse(\Psr\Http\Message\ResponseInterface response) : void
since |
2.0.0 |
---|
Arguments
- response
\Psr\Http\Message\ResponseInterface
The response object
setSession
Sets the session for the application to use, if required.
setSession(\Joomla\Session\SessionInterface session) : $this
since |
2.0.0 |
---|
Arguments
- session
\Joomla\Session\SessionInterface
A session object.
Response
$this
Properties
controllerResolver
The application's controller resolver.
since |
2.0.0 |
---|
Type(s)
\Joomla\Application\Controller\ControllerResolverInterface
router
The application's router.
since |
2.0.0 |
---|
Type(s)
\Joomla\Router\RouterInterface
session
The application session object.
since |
2.0.0 |
---|
Type(s)
\Joomla\Session\SessionInterface
input
The application input object.
since |
1.0.0 |
---|
Type(s)
\Joomla\Input\Input
charSet
Character encoding string.
since |
1.0.0 |
---|
Type(s)
string
mimeType
Response mime type.
since |
1.0.0 |
---|
Type(s)
string
httpVersion
HTTP protocol version.
since |
1.9.0 |
---|
Type(s)
string
modifiedDate
The body modified date for response headers.
since |
1.0.0 |
---|
Type(s)
\DateTime
client
The application client object.
since |
1.0.0 |
---|
Type(s)
\Joomla\Application\Web\WebClient
response
The application response object.
since |
1.0.0 |
---|
Type(s)
\Psr\Http\Message\ResponseInterface
cacheable
Is caching enabled?
since |
2.0.0 |
---|
Type(s)
bool
responseMap
A map of integer HTTP response codes to the full HTTP Status for the headers.
since |
1.6.0 |
---|---|
link |
Type(s)
array
config
The application configuration object.
since |
1.0.0 |
---|
Type(s)
\Joomla\Registry\Registry
dispatcher
Event Dispatcher
since |
1.2.0 |
---|
Type(s)
\Joomla\Event\DispatcherInterface|null
input
The application input object
Type(s)
\Joomla\Input\Input