ConsoleApplication
Extends \Joomla\Console\Application Implements \Joomla\Event\DispatcherAwareInterface, CMSApplicationInterfaceThe Joomla! CMS Console Application
since |
4.0.0 |
---|---|
package |
Joomla CMS |
Methods
__construct
Class constructor.
__construct(\Joomla\Registry\Registry config, \Joomla\Event\DispatcherInterface dispatcher, \Joomla\DI\Container container, \Joomla\CMS\Language\Language language, \Symfony\Component\Console\Input\InputInterface|null input = null, \Symfony\Component\Console\Output\OutputInterface|null output = null) : mixed
since |
4.0.0 |
---|
Arguments
- 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.- dispatcher
\Joomla\Event\DispatcherInterface
An optional argument to provide dependency injection for the application's event dispatcher. If the argument is a DispatcherInterface object that object will become the application's event dispatcher, if it is null then the default event dispatcher will be created based on the application's loadDispatcher() method.- container
\Joomla\DI\Container
Dependency injection container.- language
\Joomla\CMS\Language\Language
The language object provisioned for the application.- input
\Symfony\Component\Console\Input\InputInterface|null
An optional argument to provide dependency injection for the application's input object. If the argument is an InputInterface object that object will become the application's input object, otherwise a default input object is created.- output
\Symfony\Component\Console\Output\OutputInterface|null
An optional argument to provide dependency injection for the application's output object. If the argument is an OutputInterface object that object will become the application's output object, otherwise a default output object is created.
Response
mixed
__get
Magic method to access properties of the application.
__get(string name) : mixed
since |
4.0.0 |
---|---|
deprecated |
5.0 This is a B/C proxy for deprecated read accesses |
Arguments
- name
string
The name of the property.
Response
mixed
A value if the property name is valid, null otherwise.
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
createExtensionNamespaceMap
Allows the application to load a custom or default identity.
createExtensionNamespaceMap() : void
since |
4.0.0 |
---|
doExecute
Method to run the application routines.
doExecute() : int
since |
4.0.0 |
---|---|
throws |
|
Response
int
The exit code for the application
enqueueMessage
Enqueue a system message.
enqueueMessage(string msg, string type = self::MSG_INFO) : void
since |
4.0.0 |
---|
Arguments
- msg
string
The message to enqueue.- type
string
The message type.
execute
Execute the application.
execute() : void
since |
4.0.0 |
---|---|
throws |
|
flushAssets
Flush the media version to refresh versionable assets
flushAssets() : void
since |
4.0.0 |
---|
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
getDefaultCommands
Get the commands which should be registered by default to the application.
getDefaultCommands() : \Joomla\Console\Command\AbstractCommand[]
since |
4.0.0 |
---|
Response
\Joomla\Console\Command\AbstractCommand[]
getDefaultInputDefinition
Builds the default input definition.
getDefaultInputDefinition() : \Symfony\Component\Console\Input\InputDefinition
since |
4.2.1 |
---|
Response
\Symfony\Component\Console\Input\InputDefinition
getDispatcher
Get the event dispatcher.
getDispatcher() : \Joomla\Event\DispatcherInterface
since |
4.0.0 |
---|---|
throws |
|
Response
\Joomla\Event\DispatcherInterface
getIdentity
Get the application identity.
getIdentity() : \Joomla\CMS\User\User
since |
4.0.0 |
---|
Response
\Joomla\CMS\User\User
getInput
Method to get the application input object.
getInput() : \Joomla\Input\Input
since |
4.0.0 |
---|
Response
\Joomla\Input\Input
getLanguage
Method to get the application language object.
getLanguage() : \Joomla\CMS\Language\Language
since |
4.0.0 |
---|
Response
\Joomla\CMS\Language\Language
The language object
getLogger
Get the logger.
getLogger() : \Psr\Log\LoggerInterface
since |
4.0.0 |
---|
Response
\Psr\Log\LoggerInterface
getLongVersion
Get the long version string for the application.
getLongVersion() : string
Overrides the parent method due to conflicting use of the getName method between the console application and the CMS application interface.
since |
4.0.0 |
---|
Response
string
getMessageQueue
Get the system message queue.
getMessageQueue() : array
since |
4.0.0 |
---|
Response
array
The system message queue.
getName
Gets the name of the current running application.
getName() : string
since |
4.0.0 |
---|
Response
string
The name of the application.
getRouter
Returns the application Router object.
getRouter(string name = null, array options = array()) : \Joomla\CMS\Router\Router
since |
4.0.6 |
---|---|
throws |
|
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
getSession
Method to get the application session object.
getSession() : \Joomla\Session\SessionInterface
since |
4.0.0 |
---|
Response
\Joomla\Session\SessionInterface
The session object
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 |
4.0.0 |
---|
Arguments
- identifier
string
String identifier for the application interface
Response
bool
True if this application is of the given type client interface.
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
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
populateHttpHost
Populates the HTTP_HOST and REQUEST_URI from the URL provided in the --live-site parameter.
populateHttpHost() : void
If the URL provided is empty or invalid we will use the URL https://joomla.invalid/set/by/console/application just so that the CLI application doesn't crash when a WebApplication descendant is instantiated in it.
This is a practical workaround for using any service depending on a WebApplication descendant under CLI.
Practical example: using a component's MVCFactory which instantiates the SiteRouter service for that component which in turn relies on an instance of SiteApplication.
since |
4.2.1 |
---|---|
see |
https://github.com/joomla/joomla-cms/issues/38518 |
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
setName
Set the name of the application.
setName(string name) : void
since |
4.0.0 |
---|---|
throws |
|
Arguments
- name
string
The new application name.
setSession
Sets the session for the application to use, if required.
setSession(\Joomla\Session\SessionInterface session) : $this
since |
4.0.0 |
---|
Arguments
- session
\Joomla\Session\SessionInterface
A session object.
Response
$this
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
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
input
The input.
since |
4.0.0 |
---|
Type(s)
\Joomla\Input\Input
session
The application session object.
since |
4.0.0 |
---|
Type(s)
\Joomla\Session\SessionInterface