ApiApplication
Extends CMSApplicationJoomla! API Application class
since |
4.0.0 |
---|---|
package |
Joomla CMS |
Methods
__construct
Class constructor.
__construct(\Joomla\Input\Json input = null, \Joomla\Registry\Registry config = null, \Joomla\Application\Web\WebClient client = null, \Joomla\DI\Container container = null) :
since |
4.0.0 |
---|
Arguments
- input
Json
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
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
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.- container
Container
Dependency injection container.
Response
mixed
addFormatMap
Adds a mapping from a content type to the format stored. Note the format type cannot be overwritten.
addFormatMap( contentHeader, format) :
since |
4.0.0 |
---|
Arguments
- contentHeader
string
The content header- format
string
The content type format
Response
void
afterSessionStart
After the session has been started we need to populate it with some default values.
afterSessionStart(\Joomla\Session\SessionEvent event) :
since |
3.0.1 |
---|
Arguments
- event
SessionEvent
Session event being triggered
Response
void
bootComponent
Boots the component with the given name.
bootComponent( component) : \Joomla\CMS\Extension\ComponentInterface
bootModule
Boots the module with the given name.
bootModule( module, applicationName) : \Joomla\CMS\Extension\ModuleInterface
since |
4.0.0 |
---|
Arguments
- module
string
The module to boot- applicationName
string
The application name
Response
bootPlugin
Boots the plugin with the given name and type.
bootPlugin( plugin, type) : \Joomla\CMS\Extension\PluginInterface
since |
4.0.0 |
---|
Arguments
- plugin
string
The plugin name- type
string
The type of the plugin
Response
checkSession
Checks the user session.
checkSession() :
If the session record doesn't exist, initialise it. If session is new, create session variables
since |
3.2 |
---|---|
throws |
|
Response
void
checkToken
Checks for a form token in the request.
checkToken( method = 'post') :
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( option, view, layout, tasks) :
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
Response
void
createExtensionNamespaceMap
Allows the application to load a custom or default identity.
createExtensionNamespaceMap() :
since |
4.0.0 |
---|
Response
void
dispatch
Dispatch the application
dispatch( component = null) :
since |
4.0.0 |
---|
Arguments
- component
string
The component which is being rendered.
Response
void
doExecute
Method to run the application routines.
doExecute() :
Most likely you will want to instantiate a controller and execute it, or perform some sort of task directly.
since |
4.0.0 |
---|
Response
void
enqueueMessage
Enqueue a system message.
enqueueMessage( msg, type = self::MSG_INFO) :
since |
3.2 |
---|
Arguments
- msg
string
The message to enqueue.- type
string
The message type. Default is message.
Response
void
execute
Execute the application.
execute() :
since |
3.2 |
---|
Response
void
flushAssets
Flush the media version to refresh versionable assets
flushAssets() :
since |
3.2 |
---|
Response
void
getApiRouter
Returns the application Router object.
getApiRouter() : \Joomla\CMS\Router\ApiRouter
since |
4.0.0 |
---|---|
deprecated |
4.3 will be removed in 6.0 Inject the router or load it from the dependency injection container Example: Factory::getContainer()->get(ApiRouter::class); |
Response
getCfg
Gets a configuration value.
getCfg( varname, default = null) :
since |
3.2 |
---|---|
deprecated |
3.2 will be removed in 6.0 Use get() instead Example: Factory::getApplication()->get($varname, $default); |
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() :
since |
3.2 |
---|
Response
int
A client identifier.
getConfig
Retrieve the application configuration object.
getConfig() : \Joomla\Registry\Registry
since |
4.0.0 |
---|
Response
Registry
getContainer
Get the DI container.
getContainer() : \Joomla\DI\Container
since |
4.0.0 |
---|---|
throws |
|
Response
Container
getDispatcher
Get the event dispatcher.
getDispatcher() : \Joomla\Event\DispatcherInterface
since |
4.0.0 |
---|---|
throws |
|
Response
DispatcherInterface
getDocument
Method to get the application document object.
getDocument() : \Joomla\CMS\Document\Document
getFormToken
Method to determine a hash for anti-spoofing variable names
getFormToken( forceNew = false) :
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
getInstance
Returns a reference to the global CmsApplication object, only creating it if it doesn't already exist.
getInstance( name = null, prefix = '\JApplication', \Joomla\DI\Container container = null) : \Joomla\CMS\Application\CmsApplication
This method must be invoked as: $web = CmsApplication::getInstance();
since |
3.2 |
---|---|
throws |
|
deprecated |
4.0 will be removed in 6.0 Use the application service from the DI container instead Example: Factory::getContainer()->get($name); |
Arguments
- name
string
The name (optional) of the CmsApplication class to instantiate.- prefix
string
The class name prefix of the object.- container
Container
An optional dependency injection container to inject into the application.
Response
CmsApplication
getLanguage
Method to get the application language object.
getLanguage() : \Joomla\CMS\Language\Language
getLogger
Get the logger.
getLogger() : \Psr\Log\LoggerInterface
since |
4.0.0 |
---|
Response
LoggerInterface
getMenu
Returns the application \JMenu object.
getMenu( name = null, mixed||string|int options = []) : \Joomla\CMS\Menu\AbstractMenu
since |
3.2 |
---|
Arguments
- name
string
The name of the application/client.- options
array<string|int, mixed>
An optional associative array of configuration settings.
Response
getMessageQueue
Get the system message queue.
getMessageQueue( clear = false) : mixed||string|int
since |
3.2 |
---|
Arguments
- clear
bool
Clear the messages currently attached to the application object
Response
array<string|int, mixed>
The system message queue.
getName
Gets the name of the current running application.
getName() :
since |
3.2 |
---|
Response
string
The name of the application.
getPathway
Returns the application Pathway object.
getPathway() : \Joomla\CMS\Pathway\Pathway
getRouter
Returns the application Router object.
getRouter( name = null, mixed||string|int options = []) : \Joomla\CMS\Router\Router
since |
3.2 |
---|---|
deprecated |
4.3 will be removed in 6.0 Inject the router or load it from the dependency injection container Example: Factory::getContainer()->get($name); |
Arguments
- name
string
The name of the application.- options
array<string|int, mixed>
An optional associative array of configuration settings.
Response
getTemplate
Gets the name of the current template.
getTemplate( params = false) : string|\stdClass
since |
4.0.0 |
---|
Arguments
- params
bool
True to return the template parameters
Response
string|stdClass
getUserState
Gets a user state.
getUserState( key, default = null) :
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( key, request, default = null, type = 'none') :
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.
handlePreflight
Handles preflight requests.
handlePreflight( method, \Joomla\CMS\Router\ApiRouter router) :
since |
4.0.0 |
---|
Arguments
- method
string
The REST verb- router
ApiRouter
The API Routing object
Response
void
hasUserConfiguredTwoFactorAuthentication
No longer used
hasUserConfiguredTwoFactorAuthentication() :
since |
4.0.0 |
---|---|
throws |
|
deprecated |
4.2 will be removed in 6.0 Will be removed without replacements |
Response
bool
initialiseApp
Initialise the application.
initialiseApp(mixed||string|int options = []) :
since |
3.2 |
---|
Arguments
- options
array<string|int, mixed>
An optional associative array of configuration settings.
Response
void
isCli
Flag if the application instance is a CLI or web based application.
isCli() :
Helper function, you should use the native PHP functions to detect if it is a CLI application.
since |
4.0.0 |
---|---|
deprecated |
4.0 will be removed in 6.0 Will be removed without replacements |
Response
bool
isClient
Check the client interface by name.
isClient( identifier) :
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.
isHttpsForced
Checks if HTTPS is forced in the client configuration.
isHttpsForced( clientId = null) :
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.
isTwoFactorAuthenticationRequired
No longer used
isTwoFactorAuthenticationRequired() :
since |
4.0.0 |
---|---|
throws |
|
deprecated |
4.2 will be removed in 6.0 Will be removed without replacements |
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
Document
An optional document object. If omitted, the factory document is created.
Response
WebApplication
This method is chainable.
loadExtension
Loads the extension.
loadExtension( type, extensionName, 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
loadIdentity
Allows the application to load a custom or default identity.
loadIdentity(\Joomla\CMS\User\User identity = null) :
since |
4.0.0 |
---|
Arguments
- identity
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
Language
An optional language object. If omitted, the factory language is created.
Response
WebApplication
This method is chainable.
loadLibraryLanguage
Load the library language files for the application
loadLibraryLanguage() :
since |
3.6.3 |
---|
Response
void
loadPluginFromFilesystem
Creates a CMS plugin from the filesystem.
loadPluginFromFilesystem( plugin, type) : \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 |
4.3 will be removed in 6.0 The session should be injected as a service. |
Arguments
- session
Session
An optional session object. If omitted, the session is created.
Response
WebApplication
This method is chainable.
loadSystemUris
Method to load the system URI strings for the application.
loadSystemUris( requestUri = null) :
since |
1.7.3 |
---|
Arguments
- requestUri
string
An optional request URI to use instead of detecting one from the server environment variables.
Response
void
login
Login authentication function.
login(mixed||string|int credentials, mixed||string|int options = []) : 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<string|int, mixed>
Array('username' => string, 'password' => string)- options
array<string|int, mixed>
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( userid = null, mixed||string|int options = []) :
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<string|int, mixed>
Array('clientid' => array of client id's)
Response
bool
True on success
redirect
Redirect to another URL.
redirect( url, status = 303) :
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.
Response
void
registerEvent
Registers a handler to a particular event group.
registerEvent( event, Warning: Array to string conversion in /opt/phpdoc/vendor/twig/twig/src/Extension/CoreExtension.php on line 768 |Array handler) :
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() :
since |
4.0.0 |
---|---|
note |
Rendering should be overridden to get rid of the theme files. |
Response
void
respond
Method to send the application response to the client. All headers will be sent prior to the main application output data.
respond(mixed||string|int options = []) :
since |
4.0.0 |
---|
Arguments
- options
array<string|int, mixed>
An optional argument to enable CORS. (Temporary)
Response
void
route
Route the application.
route() :
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 |
4.0.0 |
---|
Response
void
sanityCheckSystemVariables
Ensure several core system input variables are not arrays.
sanityCheckSystemVariables() :
since |
3.9 |
---|
Response
void
setMenuFactory
Sets the internal menu factory.
setMenuFactory(\Joomla\CMS\Menu\MenuFactoryInterface menuFactory) :
setupLogging
Setup logging functionality.
setupLogging() :
since |
4.0.0 |
---|
Response
void
setUserState
Sets the value of a user state variable.
setUserState( key, value) :
since |
3.2 |
---|
Arguments
- key
string
The path of the state.- value
mixed
The value of the variable.
Response
mixed
The previous state, if one existed. Null otherwise.
toString
Sends all headers prior to returning the string
toString( compress = false) :
since |
3.2 |
---|
Arguments
- compress
bool
If true, compress the data
Response
string
triggerEvent
Calls all handlers associated with an event group.
triggerEvent( eventName, array|\Joomla\Event\Event args = []) : mixed||string|int
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 |
4.0 will be removed in 6.0 Use the Dispatcher method instead Example: Factory::getApplication()->getDispatcher()->dispatch($eventName, $event); |
Arguments
- eventName
string
The event name.- args
array<string|int, mixed>|Event
An array of arguments or an Event object (optional).
Response
array<string|int, mixed>
An array of results from each function call. Note this will be an empty array if no dispatcher is set.
Properties
JComponentTitle
The application component title.
since |
4.3.0 |
---|
Type(s)
string
item_associations
The item associations
since |
4.3.0 |
---|---|
deprecated |
4.4.0 will be removed in 6.0 as this property is not used anymore |
Type(s)
int
instance
The application instance.
since |
1.7.3 |
---|
Type(s)
static
docOptions
Array of options for the \JDocument object
since |
3.2 |
---|
Type(s)
array<string|int, mixed>
instances
Application instances container.
since |
3.2 |
---|
Type(s)
array<string|int, CmsApplication>
scope
The scope of the application.
since |
3.2 |
---|
Type(s)
string
clientId
The client identifier.
since |
4.0.0 |
---|
Type(s)
int
messageQueue
The application message queue.
since |
4.0.0 |
---|
Type(s)
array<string|int, mixed>
name
The name of the application.
since |
4.0.0 |
---|
Type(s)
string
template
Currently active template
since |
3.2 |
---|
Type(s)
object
authenticationPluginType
The authentication plugin type
since |
4.0.0 |
---|
Type(s)
string
formatMapper
Maps extension types to their
since |
4.0.0 |
---|
Type(s)
array<string|int, mixed>