JApplication
Extends \Joomla\CMS\Application\BaseApplicationBase class for a Joomla! application.
Acts as a Factory class for application specific objects and provides many supporting API functions. Derived clases should supply the route(), dispatch() and render() functions.
since |
1.5 |
---|---|
deprecated |
3.2 Use CMSApplication instead unless specified otherwise |
package |
Joomla.Legacy |
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.
__toString
Returns the response as a string.
__toString() : string
since |
1.6 |
---|---|
deprecated |
3.2 |
Response
string
The response
_createConfiguration
Create the configuration registry.
_createConfiguration(string $file) : \JConfig
since |
1.5 |
---|---|
deprecated |
3.2 |
Arguments
- $file
string
The path to the configuration file
Response
\JConfig
A JConfig object
_createSession
Create the user session.
_createSession(string $name) : \JSession
Old sessions are flushed based on the configuration value for the cookie lifetime. If an existing session, then the last access time is updated. If a new session, a session id is generated and a record is created in the #__sessions table.
since |
1.5 |
---|---|
deprecated |
3.2 |
Arguments
- $name
string
The sessions name.
Response
\JSession
JSession on success. May call exit() on database error.
afterSessionStart
After the session has been started we need to populate it with some default values.
afterSessionStart() : void
since |
3.0 |
---|---|
deprecated |
3.2 |
checkSession
Checks the user session.
checkSession() : void
If the session record doesn't exist, initialise it. If session is new, create session variables
since |
1.6 |
---|---|
deprecated |
3.2 |
close
Method to close the application.
close(integer $code) : void
since |
1.0 |
---|
Arguments
- $code
integer
The exit code (optional; default is 0).
dispatch
Dispatch the application.
dispatch(string $component = null) : void
Dispatching is the process of pulling the option from the request object and mapping them to a component. If the component does not exist, it handles determining a default component to dispatch.
since |
1.5 |
---|---|
deprecated |
3.2 |
Arguments
- $component
string
The component to dispatch.
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
enqueueMessage
Enqueue a system message.
enqueueMessage(string $msg, string $type = 'message') : void
since |
1.5 |
---|---|
deprecated |
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.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 |
---|
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.
getCfg
Gets a configuration value.
getCfg(string $varname, string $default = null) : mixed
since |
1.5 |
---|---|
deprecated |
3.2 |
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() : integer
since |
1.5 |
---|---|
deprecated |
3.2 |
Response
integer
A client identifier.
getHash
Provides a secure hash based on a seed
getHash(string $seed) : string
since |
1.6 |
---|---|
deprecated |
3.2 Use JApplicationHelper::getHash instead |
Arguments
- $seed
string
Seed string.
Response
string
A secure hash
getIdentity
Get the application identity.
getIdentity() : mixed
since |
3.0.0 |
---|
Response
mixed
A \JUser object or null.
getInstance
Returns the global JApplicationCms object, only creating it if it doesn't already exist.
getInstance(mixed $client, array $config = array(), string $prefix = 'J') : \JApplicationCms
since |
1.5 |
---|---|
deprecated |
3.2 Use JApplicationCms::getInstance() instead |
note |
As of 3.2, this proxies to JApplicationCms::getInstance() |
Arguments
- $client
mixed
A client identifier or name.- $config
array
An optional associative array of configuration settings.- $prefix
string
A prefix for class names
Response
\JApplicationCms
A JApplicationCms object.
getLogger
Get the logger.
getLogger() : \Psr\Log\LoggerInterface
since |
1.0 |
---|
Response
\Psr\Log\LoggerInterface
getMenu
Returns the application JPathway object.
getMenu(string $name = null, array $options = array()) : \JMenu|null
since |
1.5 |
---|---|
deprecated |
3.2 |
Arguments
- $name
string
The name of the application/client.- $options
array
An optional associative array of configuration settings.
Response
\JMenu|null
JMenu object.
getMessageQueue
Get the system message queue.
getMessageQueue() : array
since |
1.5 |
---|---|
deprecated |
3.2 |
Response
array
The system message queue.
getName
Method to get the application name.
getName() : string
The dispatcher name is by default parsed using the classname, or it can be set by passing a $config['name'] in the class constructor.
since |
1.5 |
---|---|
deprecated |
3.2 |
Response
string
The name of the dispatcher.
getPathway
Returns the application JPathway object.
getPathway(string $name = null, array $options = array()) : \JPathway|null
since |
1.5 |
---|---|
deprecated |
3.2 |
Arguments
- $name
string
The name of the application.- $options
array
An optional associative array of configuration settings.
Response
\JPathway|null
A JPathway object
getRouter
Returns the application JRouter object.
getRouter(string $name = null, array $options = array()) : \JRouter|null
since |
1.5 |
---|---|
deprecated |
3.2 |
Arguments
- $name
string
The name of the application.- $options
array
An optional associative array of configuration settings.
Response
\JRouter|null
A JRouter object
getTemplate
Gets the name of the current template.
getTemplate(boolean $params = false) : mixed
since |
1.5 |
---|---|
deprecated |
3.2 |
Arguments
- $params
boolean
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 |
1.5 |
---|---|
deprecated |
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 |
1.5 |
---|---|
deprecated |
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 JFilterInput::clean()}. Optional.
Response
mixed
The request user state.
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 |
---|
isAdmin
Is admin interface?
isAdmin() : boolean
since |
1.0.2 |
---|---|
deprecated |
3.2 |
Response
boolean
True if this application is administrator.
isClient
Check the client interface by name.
isClient(string $identifier) : boolean
since |
3.7.0 |
---|
Arguments
- $identifier
string
String identifier for the application interface
Response
boolean
True if this application is of the given type client interface.
isSite
Is site interface?
isSite() : boolean
since |
1.5 |
---|---|
deprecated |
3.2 |
Response
boolean
True if this application is site.
isSSLConnection
Determine if we are using a secure (SSL) connection.
isSSLConnection() : boolean
since |
3.0 |
---|---|
deprecated |
3.2 |
Response
boolean
True if using SSL, false if not.
isWinOs
Method to determine if the host OS is Windows
isWinOs() : boolean
since |
1.6 |
---|---|
deprecated |
4.0 Use the IS_WIN constant instead. |
Response
boolean
True if Windows OS
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.
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.
login
Login authentication function.
login(array $credentials, array $options = array()) : boolean|\JException
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 |
1.5 |
---|---|
deprecated |
3.2 |
Arguments
- $credentials
array
Array('username' => string, 'password' => string)- $options
array
Array('remember' => boolean)
Response
boolean|\JException
True on success, false if failed or silent handling is configured, or a JException object on authentication error.
logout
Logout authentication function.
logout(integer $userid = null, array $options = array()) : boolean
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 |
1.5 |
---|---|
deprecated |
3.2 |
Arguments
- $userid
integer
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
boolean
True on success
redirect
Redirect to another URL.
redirect(string $url, string $msg = '', string $msgType = 'message', boolean $moved = false) : void
Optionally enqueues a message in the system message queue (which will be displayed the next time a page is loaded) using the enqueueMessage method. If the headers have not been sent the redirect will be accomplished using a "301 Moved Permanently" 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.5 |
---|---|
deprecated |
3.2 |
see | \JApplication::enqueueMessage() |
Arguments
- $url
string
The URL to redirect to. Can only be http/https URL- $msg
string
An optional message to display on redirect.- $msgType
string
An optional message type. Defaults to message.- $moved
boolean
True if the page is 301 Permanently Moved, otherwise 303 See Other is assumed.
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
Render the application.
render() : void
Rendering is the process of pushing the document buffers into the template placeholders, retrieving data from the document and pushing it into the JResponse buffer.
since |
1.5 |
---|---|
deprecated |
3.2 |
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 |
1.5 |
---|---|
deprecated |
3.2 |
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
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.
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.
setUserState
Sets the value of a user state variable.
setUserState(string $key, string $value) : mixed
since |
1.5 |
---|---|
deprecated |
3.2 |
Arguments
- $key
string
The path of the state.- $value
string
The value of the variable.
Response
mixed
The previous state, if one existed.
stringURLSafe
This method transliterates a string into a URL safe string or returns a URL safe UTF-8 string based on the global configuration
stringURLSafe(string $string) : string
since |
1.6 |
---|---|
deprecated |
3.2 Use JApplicationHelper::stringURLSafe instead |
Arguments
- $string
string
String to process
Response
string
Processed string
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
_clientId
The client identifier.
since |
1.5 |
---|---|
deprecated |
3.2 |
Type(s)
integer
_messageQueue
The application message queue.
since |
1.5 |
---|---|
deprecated |
3.2 |
Type(s)
array
_name
The name of the application.
since |
1.5 |
---|---|
deprecated |
3.2 |
Type(s)
array
scope
The scope of the application.
since |
1.5 |
---|---|
deprecated |
3.2 |
Type(s)
string
requestTime
The time the request was made.
since |
1.5 |
---|---|
deprecated |
3.2 |
Type(s)
string
startTime
The time the request was made as Unix timestamp.
since |
1.6 |
---|---|
deprecated |
3.2 |
Type(s)
integer
client
The application client object.
since |
3.0 |
---|---|
deprecated |
3.2 |
Type(s)
\JApplicationWebClient
instances
JApplication instances container.
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