SiteApplication
Extends CMSApplicationJoomla! Site Application class
since |
3.2 |
---|---|
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) : mixed
since |
1.7.3 |
---|
Arguments
- input
\Joomla\CMS\Input\Input
An 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\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.- client
\Joomla\Application\Web\WebClient
An 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\ResponseInterface
An 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) : void
since |
3.0.1 |
---|
Arguments
- event
\Joomla\Session\SessionEvent
Session event being triggered
authorise
Check if the user can access the application
authorise(int itemid) : void
since |
3.2 |
---|---|
throws |
|
Arguments
- itemid
int
The item ID to check authorisation for
bootComponent
Boots the component with the given name.
bootComponent(string component) : \Joomla\CMS\Extension\ComponentInterface
since |
4.0.0 |
---|
Arguments
- component
string
The component to boot.
Response
\Joomla\CMS\Extension\ComponentInterface
bootModule
Boots the module with the given name.
bootModule(string module, string applicationName) : \Joomla\CMS\Extension\ModuleInterface
since |
4.0.0 |
---|
Arguments
- module
string
The module to boot- applicationName
string
The application name
Response
\Joomla\CMS\Extension\ModuleInterface
bootPlugin
Boots the plugin with the given name and type.
bootPlugin(string plugin, string type) : \Joomla\CMS\Extension\PluginInterface
since |
4.0.0 |
---|
Arguments
- plugin
string
The plugin name- type
string
The type of the plugin
Response
\Joomla\CMS\Extension\PluginInterface
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 |
|
checkToken
Checks for a form token in the request.
checkToken(string method = 'post') : bool
Use in conjunction with getFormToken.
since |
4.0.0 |
---|
Arguments
- method
string
The request method in which to look for the token key.
Response
bool
True if found and valid, false otherwise.
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.
throws |
|
---|
Arguments
- option
string
The option that manage the password reset- view
string
The view that manage the password reset- layout
string
The layout of the view that manage the password reset- tasks
string
Permitted tasks
createExtensionNamespaceMap
Allows the application to load a custom or default identity.
createExtensionNamespaceMap() : void
since |
4.0.0 |
---|
decryptLegacyTFAString
Tries to decrypt the legacy MFA configuration.
decryptLegacyTFAString(string secret, string stringToDecrypt) : string
see |
https://github.com/joomla/joomla-cms/pull/12497 |
---|---|
since |
4.2.0 |
Arguments
- secret
string
Site's secret key- stringToDecrypt
string
Base64-encoded and encrypted, JSON-encoded information
Response
string
Decrypted, but JSON-encoded, information
dispatch
Dispatch the application
dispatch(string component = null) : void
since |
3.2 |
---|
Arguments
- component
string
The component which is being rendered.
doExecute
Method to run the Web application routines.
doExecute() : void
since |
3.2 |
---|
enqueueMessage
Enqueue a system message.
enqueueMessage(string msg, string type = self::MSG_INFO) : void
since |
3.2 |
---|
Arguments
- msg
string
The message to enqueue.- type
string
The message type. Default is message.
execute
Execute the application.
execute() : void
since |
1.7.3 |
---|
flushAssets
Flush the media version to refresh versionable assets
flushAssets() : void
since |
3.2 |
---|
getCacheControllerFactory
Get the CacheControllerFactoryInterface.
getCacheControllerFactory() : \Joomla\CMS\Cache\CacheControllerFactoryInterface
since |
4.2.0 |
---|
Response
\Joomla\CMS\Cache\CacheControllerFactoryInterface
getCfg
Gets a configuration value.
getCfg(string varname, string default = null) : mixed
since |
3.2 |
---|---|
deprecated |
5.0 Use get() instead |
Arguments
- varname
string
The name of the value to get.- default
string
Default value to return
Response
mixed
The user state.
getClientId
Gets the client id of the current running application.
getClientId() : int
since |
3.2 |
---|
Response
int
A client identifier.
getConfig
Retrieve the application configuration object.
getConfig() : \Joomla\Registry\Registry
since |
4.0.0 |
---|
Response
\Joomla\Registry\Registry
getContainer
Get the DI container.
getContainer() : \Joomla\DI\Container
since |
4.0.0 |
---|---|
throws |
|
Response
\Joomla\DI\Container
getDetectBrowser
Return the current state of the detect browser option.
getDetectBrowser() : bool
since |
3.2 |
---|
Response
bool
getDispatcher
Get the event dispatcher.
getDispatcher() : \Joomla\Event\DispatcherInterface
since |
4.0.0 |
---|---|
throws |
|
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\Document
The document object
getFormToken
Method to determine a hash for anti-spoofing variable names
getFormToken(bool forceNew = false) : string
since |
4.0.0 |
---|
Arguments
- forceNew
bool
If true, force a new token to be created
Response
string
Hashed var name
getIdentity
Get the application identity.
getIdentity() : \Joomla\CMS\User\User
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
This method must be invoked as: $web = WebApplication::getInstance();
since |
1.7.3 |
---|---|
throws |
|
deprecated |
5.0 Use \Joomla\CMS\Factory::getContainer()->get($name) instead |
Arguments
- name
string
The name (optional) of the WebApplication 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\Language
The language object
getLanguageFilter
Return the current state of the language filter.
getLanguageFilter() : bool
since |
3.2 |
---|
Response
bool
getLogger
Get the logger.
getLogger() : \Psr\Log\LoggerInterface
since |
4.0.0 |
---|
Response
\Psr\Log\LoggerInterface
getMenu
Returns the application \JMenu object.
getMenu(string name = null, array options = array()) : \Joomla\CMS\Menu\AbstractMenu
since |
3.2 |
---|
Arguments
- name
string
The name of the application/client.- options
array
An optional associative array of configuration settings.
Response
\Joomla\CMS\Menu\AbstractMenu
getMessageQueue
Get the system message queue.
getMessageQueue(bool clear = false) : array
since |
3.2 |
---|
Arguments
- clear
bool
Clear the messages currently attached to the application object
Response
array
The system message queue.
getName
Gets the name of the current running application.
getName() : string
since |
3.2 |
---|
Response
string
The name of the application.
getParams
Get the application parameters
getParams(string option = null) : \Joomla\Registry\Registry
since |
3.2 |
---|
Arguments
- option
string
The component option
Response
\Joomla\Registry\Registry
The parameters object
getPathway
Returns the application Pathway object.
getPathway() : \Joomla\CMS\Pathway\Pathway
since |
3.2 |
---|
Response
\Joomla\CMS\Pathway\Pathway
getRouter
Returns the application Router object.
getRouter(string name = null, array options = array()) : \Joomla\CMS\Router\Router
since |
3.2 |
---|---|
deprecated |
5.0 Inject the router or load it from the dependency injection container |
Arguments
- name
string
The name of the application.- options
array
An optional associative array of configuration settings.
Response
\Joomla\CMS\Router\Router
getTemplate
Gets the name of the current template.
getTemplate(bool params = false) : mixed
since |
3.2 |
---|
Arguments
- params
bool
An optional associative array of configuration settings
Response
mixed
System is the fallback.
getUserState
Gets a user state.
getUserState(string key, mixed default = null) : mixed
since |
3.2 |
---|
Arguments
- key
string
The path of the state.- default
mixed
Optional default value, returned if the internal value is null.
Response
mixed
The 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
string
The key of the user state variable.- request
string
The name of the variable passed in a request.- default
string
The default value for the variable if not found. Optional.- type
string
Filter for the variable, for valid values see {@link InputFilter::clean()}. Optional.
Response
mixed
The request user state.
hasRejectedMultiFactorAuthenticationSetup
Does the user have a "don't show this again" flag?
hasRejectedMultiFactorAuthenticationSetup() : bool
since |
4.2.0 |
---|
Response
bool
hasUserConfiguredTwoFactorAuthentication
No longer used
hasUserConfiguredTwoFactorAuthentication() : bool
since |
4.0.0 |
---|---|
throws |
|
deprecated |
4.2.0 Will be removed in 5.0 without replacement. |
Response
bool
initialiseApp
Initialise the application.
initialiseApp(array options = array()) : void
since |
3.2 |
---|
Arguments
- options
array
An optional associative array of configuration settings.
isCli
Flag if the application instance is a CLI or web based application.
isCli() : bool
Helper function, you should use the native PHP functions to detect if it is a CLI application.
since |
4.0.0 |
---|---|
deprecated |
5.0 Will be removed without replacements |
Response
bool
isClient
Check the client interface by name.
isClient(string identifier) : bool
since |
3.7.0 |
---|
Arguments
- identifier
string
String identifier for the application interface
Response
bool
True if this application is of the given type client interface.
isHandlingMultiFactorAuthentication
Handle the redirection to the Multi-factor Authentication captive login or setup page.
isHandlingMultiFactorAuthentication() : bool
throws |
|
---|---|
since |
4.2.0 |
Response
bool
True if we are currently handling a Multi-factor Authentication captive page.
isHttpsForced
Checks if HTTPS is forced in the client configuration.
isHttpsForced(int clientId = null) : bool
since |
3.7.3 |
---|
Arguments
- clientId
int
An optional client id (defaults to current application client).
Response
bool
True if is forced for the client, false otherwise.
isMultiFactorAuthenticationPage
Is this a page concerning the Multi-factor Authentication feature?
isMultiFactorAuthenticationPage(bool onlyCaptive = false) : bool
since |
4.2.0 |
---|
Arguments
- onlyCaptive
bool
Should I only check for the MFA captive page?
Response
bool
isMultiFactorAuthenticationPending
Does the current user need to complete MFA authentication before being allowed to access the site?
isMultiFactorAuthenticationPending() : bool
throws |
|
---|---|
since |
4.2.0 |
Response
bool
isTwoFactorAuthenticationRequired
No longer used
isTwoFactorAuthenticationRequired() : bool
since |
4.0.0 |
---|---|
throws |
|
deprecated |
4.2.0 Will be removed in 5.0 without replacement. |
Response
bool
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\Document
An optional document object. If omitted, the factory document is created.
Response
\Joomla\CMS\Application\WebApplication
This method is chainable.
loadExtension
Loads the extension.
loadExtension(string type, string extensionName, string extensionPath) : \Joomla\CMS\Extension\ComponentInterface|\Joomla\CMS\Extension\ModuleInterface|\Joomla\CMS\Extension\PluginInterface
since |
4.0.0 |
---|
Arguments
- type
string
The extension type- extensionName
string
The extension name- extensionPath
string
The path of the extension
Response
\Joomla\CMS\Extension\ComponentInterface|\Joomla\CMS\Extension\ModuleInterface|\Joomla\CMS\Extension\PluginInterface
loadIdentity
Allows the application to load a custom or default identity.
loadIdentity(\Joomla\CMS\User\User identity = null) : $this
since |
4.0.0 |
---|
Arguments
- identity
\Joomla\CMS\User\User
An 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\Language
An optional language object. If omitted, the factory language is created.
Response
\Joomla\CMS\Application\WebApplication
This method is chainable.
loadLibraryLanguage
Load the library language files for the application
loadLibraryLanguage() : void
since |
3.6.3 |
---|
loadPluginFromFilesystem
Creates a CMS plugin from the filesystem.
loadPluginFromFilesystem(string plugin, string type) : \Joomla\CMS\Plugin\CMSPlugin
since |
4.0.0 |
---|
Arguments
- plugin
string
The plugin- type
string
The type
Response
\Joomla\CMS\Plugin\CMSPlugin
loadSession
Allows the application to load a custom or default session.
loadSession(\Joomla\CMS\Session\Session 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 |
---|---|
deprecated |
5.0 The session should be injected as a service. |
Arguments
- session
\Joomla\CMS\Session\Session
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.
login
Login authentication function.
login(array credentials, array options = array()) : bool|\Exception
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
array
Array('username' => string, 'password' => string)- options
array
Array('remember' => boolean)
Response
bool|\Exception
True on success, false if failed or silent handling is configured, or a \Exception 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
int
The user to load - Can be an integer or string - If string, it is converted to ID automatically- options
array
Array('clientid' => array of client id's)
Response
bool
True on success
migrateFromLegacyMFA
Automatically migrates a user's legacy MFA records into the new Captive MFA format.
migrateFromLegacyMFA() : void
since |
4.2.0 |
---|
needsMultiFactorAuthenticationRedirection
Check whether we'll need to do a redirection to the Multi-factor Authentication captive page.
needsMultiFactorAuthenticationRedirection() : bool
since |
4.2.0 |
---|
Response
bool
redirect
Redirect to another URL.
redirect(string url, int 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 |
3.2 |
---|
Arguments
- url
string
The URL to redirect to. Can only be http/https URL- status
int
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) : $this
since |
4.0.0 |
---|
Arguments
- event
string
The event name.- handler
callable
The 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 |
---|
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 |
---|---|
deprecated |
5.0 Implement the route functionality in the extending class, this here will be removed without replacement |
sanityCheckSystemVariables
Ensure several core system input variables are not arrays.
sanityCheckSystemVariables() : void
since |
3.9 |
---|
setCacheControllerFactory
Set the cache controller factory to use.
setCacheControllerFactory(\Joomla\CMS\Cache\CacheControllerFactoryInterface cacheControllerFactory = null) : void
since |
4.2.0 |
---|
Arguments
- cacheControllerFactory
\Joomla\CMS\Cache\CacheControllerFactoryInterface
The cache controller factory to use.
setDetectBrowser
Set the current state of the detect browser option.
setDetectBrowser(bool state = false) : bool
since |
3.2 |
---|
Arguments
- state
bool
The new state of the detect browser option
Response
bool
The previous state
setLanguageFilter
Set the current state of the language filter.
setLanguageFilter(bool state = false) : bool
since |
3.2 |
---|
Arguments
- state
bool
The new state of the language filter
Response
bool
The previous state
setMenuFactory
Sets the internal menu factory.
setMenuFactory(\Joomla\CMS\Menu\MenuFactoryInterface menuFactory) : void
since |
4.2.0 |
---|
Arguments
- menuFactory
\Joomla\CMS\Menu\MenuFactoryInterface
The menu factory
setTemplate
Overrides the default template that would be used
setTemplate(\stdClass|string template, mixed styleParams = null) : void
since |
3.2 |
---|
Arguments
- template
\stdClass|string
The template name or definition- styleParams
mixed
The template style parameters
setupLogging
Setup logging functionality.
setupLogging() : void
since |
4.0.0 |
---|
setUserFactory
Set the user factory to use.
setUserFactory(\Joomla\CMS\User\UserFactoryInterface userFactory) : void
since |
4.0.0 |
---|
Arguments
- userFactory
\Joomla\CMS\User\UserFactoryInterface
The user factory to use
setUserState
Sets the value of a user state variable.
setUserState(string key, mixed value) : mixed|void
since |
3.2 |
---|
Arguments
- key
string
The path of the state.- value
mixed
The value of the variable.
Response
mixed|void
The previous state, if one existed.
toString
Sends all headers prior to returning the string
toString(bool compress = false) : string
since |
3.2 |
---|
Arguments
- compress
bool
If true, compress the data
Response
string
triggerEvent
Calls all handlers associated with an event group.
triggerEvent(string eventName, array|\Joomla\Event\Event args = []) : array
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 |
|
deprecated |
5.0 |
Arguments
- eventName
string
The event name.- args
array|\Joomla\Event\Event
An array of arguments or an Event object (optional).
Response
array
An array of results from each function call. Note this will be an empty array if no dispatcher is set.
Properties
cacheControllerFactory
CacheControllerFactoryInterface