CliApplication

Extends AbstractApplication Implements DispatcherAwareInterface, CMSApplicationInterface

Base class for a Joomla! command line application.

abstract deprecated
since

2.5.0

deprecated

4.0 will be removed in 6.0 Use the ConsoleApplication instead

package

Joomla CMS

Methods

__construct

Class constructor.

__construct(\Joomla\Input\Input input = null, \Joomla\Registry\Registry config = null, \Joomla\CMS\Application\CLI\CliOutput output = null, \Joomla\CMS\Application\CLI\CliInput cliInput = null, \Joomla\Event\DispatcherInterface dispatcher = null, \Joomla\DI\Container container = null) : 
since

1.7.0

Arguments

input

InputAn optional argument to provide dependency injection for the application's input object. If the argument is a JInputCli object that object will become the application's input object, otherwise a default input object is created.

config

RegistryAn 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.

output

CliOutputThe output handler.

cliInput

CliInputThe CLI input handler.

dispatcher

DispatcherInterfaceAn 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

ContainerDependency injection container.

Response

mixed

__get

Magic method to access properties of the application.

__get( name) : 
deprecated
since

4.0.0

deprecated

4.0 will be removed in 6.0 This is a B/C proxy for deprecated read accesses Example: Factory::getApplication()->getInput();

Arguments

name

stringThe name of the property.

Response

mixedA value if the property name is valid, null otherwise.

bootComponent

Boots the component with the given name.

bootComponent( component) : \Joomla\CMS\Extension\ComponentInterface
inherited
since

4.0.0

Arguments

component

stringThe component to boot.

Response

ComponentInterface

bootModule

Boots the module with the given name.

bootModule( module,  applicationName) : \Joomla\CMS\Extension\ModuleInterface
inherited
since

4.0.0

Arguments

module

stringThe module to boot

applicationName

stringThe application name

Response

ModuleInterface

bootPlugin

Boots the plugin with the given name and type.

bootPlugin( plugin,  type) : \Joomla\CMS\Extension\PluginInterface
inherited
since

4.0.0

Arguments

plugin

stringThe plugin name

type

stringThe type of the plugin

Response

PluginInterface

createExtensionNamespaceMap

Allows the application to load a custom or default identity.

createExtensionNamespaceMap() : 
inherited
since

4.0.0

Response

void

enqueueMessage

Enqueue a system message.

enqueueMessage( msg,  type = self::MSG_INFO) : 
since

4.0.0

Arguments

msg

stringThe message to enqueue.

type

stringThe message type.

Response

void

execute

Execute the application.

execute() : 
since

1.7.0

Response

void

getCliInput

Get a CLI input object.

getCliInput() : \Joomla\CMS\Application\CLI\CliInput
since

4.0.0

Response

CliInput

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
inherited abstract
since

4.0.0

throws

ContainerNotFoundExceptionMay be thrown if the container has not been set.

Response

Container

getDispatcher

Get the event dispatcher.

getDispatcher() : \Joomla\Event\DispatcherInterface
inherited abstract
since

4.0.0

throws

UnexpectedValueExceptionMay be thrown if the dispatcher has not been set.

Response

DispatcherInterface

getIdentity

Get the application identity.

getIdentity() : \Joomla\CMS\User\User
inherited
since

4.0.0

Response

User

getInput

Method to get the application input object.

getInput() : \Joomla\Input\Input
since

4.0.0

Response

Input

getInstance

Returns a reference to the global CliApplication object, only creating it if it doesn't already exist.

getInstance( name = null) : \Joomla\CMS\Application\CliApplication
static deprecated

This method must be invoked as: $cli = CliApplication::getInstance();

since

1.7.0

deprecated

4.0 will be removed in 6.0 Load the app through the container or via the Factory Example: Factory::getContainer()->get(CliApplication::class)

throws

RuntimeException

Arguments

name

stringThe name (optional) of the Application Cli class to instantiate.

Response

CliApplication

getLanguage

Method to get the application language object.

getLanguage() : \Joomla\CMS\Language\Language
since

4.0.0

Response

LanguageThe language object

getLogger

Get the logger.

getLogger() : \Psr\Log\LoggerInterface
inherited abstract
since

4.0.0

Response

LoggerInterface

getMessageQueue

Get the system message queue.

getMessageQueue() : mixed||string|int
since

4.0.0

Response

array<string|int, mixed>The system message queue.

getOutput

Get an output object.

getOutput() : \Joomla\CMS\Application\CLI\CliOutput
since

4.0.0

Response

CliOutput

getSession

Method to get the application session object.

getSession() : \Joomla\Session\SessionInterface
since

4.0.0

Response

SessionInterfaceThe session object

in

Get a value from standard input.

in() : 
since

4.0.0

Response

stringThe input string from standard input.

isCli

Flag if the application instance is a CLI or web based application.

isCli() : 
deprecated

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

4.0.0

Arguments

identifier

stringString identifier for the application interface

Response

boolTrue if this application is of the given type client interface.

loadExtension

Loads the extension.

loadExtension( type,  extensionName,  extensionPath) : \Joomla\CMS\Extension\ComponentInterface|\Joomla\CMS\Extension\ModuleInterface|\Joomla\CMS\Extension\PluginInterface
inherited
since

4.0.0

Arguments

type

stringThe extension type

extensionName

stringThe extension name

extensionPath

stringThe path of the extension

Response

ComponentInterface|ModuleInterface|PluginInterface

loadIdentity

Allows the application to load a custom or default identity.

loadIdentity(\Joomla\CMS\User\User identity = null) : 
inherited
since

4.0.0

Arguments

identity

UserAn optional identity object. If omitted, a null user object is created.

Response

$this

loadPluginFromFilesystem

Creates a CMS plugin from the filesystem.

loadPluginFromFilesystem( plugin,  type) : \Joomla\CMS\Plugin\CMSPlugin
inherited
since

4.0.0

Arguments

plugin

stringThe plugin

type

stringThe type

Response

CMSPlugin

out

Write a string to standard output.

out( text = '',  nl = true) : 
since

4.0.0

Arguments

text

stringThe text to display.

nl

boolTrue (default) to append a new line at the end of the output string.

Response

$this

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) : 
inherited
since

4.0.0

Arguments

event

stringThe event name.

handler

callableThe handler, a function or an instance of an event object.

Response

$this

setOutput

Set an output object.

setOutput(\Joomla\CMS\Application\CLI\CliOutput output) : 
since

3.3

Arguments

output

CliOutputCliOutput object

Response

$this

triggerEvent

Calls all handlers associated with an event group.

triggerEvent( eventName, array|\Joomla\Event\Event args = []) : mixed||string|int
inherited deprecated

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

InvalidArgumentException

deprecated

4.0 will be removed in 6.0 Use the Dispatcher method instead Example: Factory::getApplication()->getDispatcher()->dispatch($eventName, $event);

Arguments

eventName

stringThe event name.

args

array<string|int, mixed>|EventAn 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

identity

The application identity object.

inherited
since

4.0.0

Type(s)

User

output

Output object

since

4.0.0

Type(s)

CliOutput

input

The input.

since

4.0.0

Type(s)

Input

cliInput

CLI Input object

since

4.0.0

Type(s)

CliInput

language

The application language object.

since

4.0.0

Type(s)

Language

messages

The application message queue.

since

4.0.0

Type(s)

array<string|int, mixed>

instance

The application instance.

static
since

1.7.0

Type(s)

CliApplication