Application

Extends AbstractApplication

Base application class for a Joomla! command line application.

since

2.0.0

package

Joomla Framework

Methods

__construct

Class constructor.

__construct(\Joomla\Registry\Registry|null config = null) : mixed
inherited
since

1.0.0

Arguments

config

\Joomla\Registry\Registry|nullAn 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.

Response

mixed

addCommand

Adds a command object.

addCommand(\Joomla\Console\Command\AbstractCommand command) : \Joomla\Console\Command\AbstractCommand

If a command with the same name already exists, it will be overridden. If the command is not enabled it will not be added.

since

2.0.0

throws

\Symfony\Component\Console\Exception\LogicException

Arguments

command

\Joomla\Console\Command\AbstractCommandThe command to add to the application.

Response

\Joomla\Console\Command\AbstractCommand

close

Method to close the application.

close(int code) : void
inherited
since

1.0.0

Arguments

code

intThe exit code (optional; default is 0).

configureIO

Configures the console input and output instances for the process.

configureIO() : void
since

2.0.0

dispatchEvent

Dispatches an application event if the dispatcher has been set.

dispatchEvent(string eventName, \Joomla\Event\EventInterface|null event = null) : \Joomla\Event\EventInterface|null
inherited
since

2.0.0

Arguments

eventName

stringThe event to dispatch.

event

\Joomla\Event\EventInterface|nullThe event object.

Response

\Joomla\Event\EventInterface|nullThe dispatched event or null if no dispatcher is set

doExecute

Method to run the application routines.

doExecute() : mixed
inherited abstract

Most likely you will want to instantiate a controller and execute it, or perform some sort of task directly.

since

1.0.0

Response

mixed

doRenderThrowable

Handles recursively rendering error messages for a Throwable and all previous Throwables contained within.

doRenderThrowable(\Throwable throwable, \Symfony\Component\Console\Output\OutputInterface output) : void
since

2.0.0

Arguments

throwable

\ThrowableThe Throwable object to render the message for.

output

\Symfony\Component\Console\Output\OutputInterfaceThe output object to send the message to.

execute

Execute the application.

execute() : void
inherited
since

1.0.0

extractAllNamespaces

Returns all namespaces of the command name.

extractAllNamespaces(string name) : string[]
since

2.0.0

Arguments

name

stringThe full name of the command

Response

string[]

extractNamespace

Returns the namespace part of the command name.

extractNamespace(string name, int limit = null) : string
since

2.0.0

Arguments

name

stringThe command name to process

limit

intThe maximum number of parts of the namespace

Response

string

findNamespace

Finds a registered namespace by a name.

findNamespace(string namespace) : string
since

2.0.0

throws

\Joomla\Console\Exception\NamespaceNotFoundExceptionWhen namespace is incorrect or ambiguous

Arguments

namespace

stringA namespace to search for

Response

string

get

Returns a property of the object or the default value if the property is not set.

get(string key, mixed default = null) : mixed
inherited
since

1.0.0

Arguments

key

stringThe name of the property.

default

mixedThe default value (optional) if none is set.

Response

mixedThe value of the configuration.

getAllCommands

Gets all commands, including those available through a command loader, optionally filtered on a command namespace.

getAllCommands(string namespace = '') : \Joomla\Console\Command\AbstractCommand[]
since

2.0.0

Arguments

namespace

stringAn optional command namespace to filter by.

Response

\Joomla\Console\Command\AbstractCommand[]

getCommand

Returns a registered command by name or alias.

getCommand(string name) : \Joomla\Console\Command\AbstractCommand
since

2.0.0

throws

\Symfony\Component\Console\Exception\CommandNotFoundException

Arguments

name

stringThe command name or alias

Response

\Joomla\Console\Command\AbstractCommand

getCommandName

Get the name of the command to run.

getCommandName(\Symfony\Component\Console\Input\InputInterface input) : string|null
since

2.0.0

Arguments

input

\Symfony\Component\Console\Input\InputInterfaceThe input to read the argument from

Response

string|null

getCommands

Get the registered commands.

getCommands() : \Joomla\Console\Command\AbstractCommand[]

This method only retrieves commands which have been explicitly registered. To get all commands including those from a command loader, use the getAllCommands() method.

since

2.0.0

Response

\Joomla\Console\Command\AbstractCommand[]

getConsoleInput

Get the console input handler.

getConsoleInput() : \Symfony\Component\Console\Input\InputInterface
since

2.0.0

Response

\Symfony\Component\Console\Input\InputInterface

getConsoleOutput

Get the console output handler.

getConsoleOutput() : \Symfony\Component\Console\Output\OutputInterface
since

2.0.0

Response

\Symfony\Component\Console\Output\OutputInterface

getDefaultCommands

Get the commands which should be registered by default to the application.

getDefaultCommands() : \Joomla\Console\Command\AbstractCommand[]
since

2.0.0

Response

\Joomla\Console\Command\AbstractCommand[]

getDefaultHelperSet

Builds the default helper set.

getDefaultHelperSet() : \Symfony\Component\Console\Helper\HelperSet
since

2.0.0

Response

\Symfony\Component\Console\Helper\HelperSet

getDefaultInputDefinition

Builds the default input definition.

getDefaultInputDefinition() : \Symfony\Component\Console\Input\InputDefinition
since

2.0.0

Response

\Symfony\Component\Console\Input\InputDefinition

getDefinition

Gets the InputDefinition related to this Application.

getDefinition() : \Symfony\Component\Console\Input\InputDefinition
since

2.0.0

Response

\Symfony\Component\Console\Input\InputDefinition

getDispatcher

Get the event dispatcher.

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

1.2.0

throws

\UnexpectedValueExceptionMay be thrown if the dispatcher has not been set.

Response

\Joomla\Event\DispatcherInterface

getHelperSet

Get the helper set associated with the application.

getHelperSet() : \Symfony\Component\Console\Helper\HelperSet

Response

\Symfony\Component\Console\Helper\HelperSet

getLogger

Get the logger.

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

1.0.0

Response

\Psr\Log\LoggerInterface

getLongVersion

Get the long version string for the application.

getLongVersion() : string

Typically, this is the application name and version and is used in the application help output.

since

2.0.0

Response

string

getName

Get the name of the application.

getName() : string
since

2.0.0

Response

string

getNamespaces

Returns an array of all unique namespaces used by currently registered commands.

getNamespaces() : string[]

Note that this does not include the global namespace which always exists.

since

2.0.0

Response

string[]

getVersion

Get the version of the application.

getVersion() : string
since

2.0.0

Response

string

hasCommand

Check if the application has a command with the given name.

hasCommand(string name) : bool
since

2.0.0

Arguments

name

stringThe name of the command to check for existence.

Response

bool

initCommands

Internal function to initialise the command store, this allows the store to be lazy loaded only when needed.

initCommands() : void
since

2.0.0

initialise

Custom initialisation method.

initialise() : void
inherited

Called at the end of the AbstractApplication::__construct method. This is for developers to inject initialisation code for their application classes.

since

1.0.0

renderThrowable

Renders an error message for a Throwable object

renderThrowable(\Throwable throwable) : void
since

2.0.0

Arguments

throwable

\ThrowableThe Throwable object to render the message for.

runCommand

Run the given command.

runCommand(\Joomla\Console\Command\AbstractCommand command, \Symfony\Component\Console\Input\InputInterface input, \Symfony\Component\Console\Output\OutputInterface output) : int
since

2.0.0

throws

\Throwable

Arguments

command

\Joomla\Console\Command\AbstractCommandThe command to run.

input

\Symfony\Component\Console\Input\InputInterfaceThe input to inject into the command.

output

\Symfony\Component\Console\Output\OutputInterfaceThe output to inject into the command.

Response

int

set

Modifies a property of the object, creating it if it does not already exist.

set(string key, mixed value = null) : mixed
inherited
since

1.0.0

Arguments

key

stringThe name of the property.

value

mixedThe value of the property to set (optional).

Response

mixedPrevious value of the property

setAutoExit

Set whether the application should auto exit.

setAutoExit(bool autoExit) : void
since

2.0.0

Arguments

autoExit

boolThe auto exit state.

setCatchThrowables

Set whether the application should catch Throwables.

setCatchThrowables(bool catchThrowables) : void
since

2.0.0

Arguments

catchThrowables

boolThe catch Throwables state.

setCommandLoader

Set the command loader.

setCommandLoader(\Joomla\Console\Loader\LoaderInterface loader) : void
since

2.0.0

Arguments

loader

\Joomla\Console\Loader\LoaderInterfaceThe new command loader.

setConfiguration

Sets the configuration for the application.

setConfiguration(\Joomla\Registry\Registry config) : $this
inherited
since

1.0.0

Arguments

config

\Joomla\Registry\RegistryA registry object holding the configuration.

Response

$this

setDispatcher

Set the dispatcher to use.

setDispatcher(\Joomla\Event\DispatcherInterface dispatcher) : $this
inherited
since

1.2.0

Arguments

dispatcher

\Joomla\Event\DispatcherInterfaceThe dispatcher to use.

Response

$this

setHelperSet

Set the application's helper set.

setHelperSet(\Symfony\Component\Console\Helper\HelperSet helperSet) : void
since

2.0.0

Arguments

helperSet

\Symfony\Component\Console\Helper\HelperSetThe new HelperSet.

setName

Set the name of the application.

setName(string name) : void
since

2.0.0

Arguments

name

stringThe new application name.

setVersion

Set the version of the application.

setVersion(string version) : void
since

2.0.0

Arguments

version

stringThe new application version.

shouldAutoExit

Get the application's auto exit state.

shouldAutoExit() : bool
since

2.0.0

Response

bool

shouldCatchThrowables

Get the application's catch Throwables state.

shouldCatchThrowables() : bool
since

2.0.0

Response

bool

splitStringByWidth

Splits a string for a specified width for use in an output.

splitStringByWidth(string string, int width) : string[]
since

2.0.0

Arguments

string

stringThe string to split.

width

intThe maximum width of the output.

Response

string[]

Properties

autoExit

Flag indicating the application should automatically exit after the command is run.

since

2.0.0

Type(s)

bool

catchThrowables

Flag indicating the application should catch and handle Throwables.

since

2.0.0

Type(s)

bool

commands

The available commands.

since

2.0.0

Type(s)

\Joomla\Console\Command\AbstractCommand[]

commandLoader

The command loader.

since

2.0.0

Type(s)

\Joomla\Console\Loader\LoaderInterface|null

consoleInput

Console input handler.

since

2.0.0

Type(s)

\Symfony\Component\Console\Input\InputInterface

consoleOutput

Console output handler.

since

2.0.0

Type(s)

\Symfony\Component\Console\Output\OutputInterface

defaultCommand

The default command for the application.

since

2.0.0

Type(s)

string

definition

The application input definition.

since

2.0.0

Type(s)

\Symfony\Component\Console\Input\InputDefinition|null

helperSet

The application helper set.

since

2.0.0

Type(s)

\Symfony\Component\Console\Helper\HelperSet|null

initialised

Internal flag tracking if the command store has been initialised.

since

2.0.0

Type(s)

bool

name

The name of the application.

since

2.0.0

Type(s)

string

runningCommand

Reference to the currently running command.

since

2.0.0

Type(s)

\Joomla\Console\Command\AbstractCommand|null

terminal

The console terminal helper.

since

2.0.0

Type(s)

\Symfony\Component\Console\Terminal

version

The version of the application.

since

2.0.0

Type(s)

string

wantsHelp

Internal flag tracking if the user is seeking help for the given command.

since

2.0.0

Type(s)

bool

config

The application configuration object.

inherited
since

1.0.0

Type(s)

\Joomla\Registry\Registry

dispatcher

Event Dispatcher

inherited
since

1.2.0

Type(s)

\Joomla\Event\DispatcherInterface|null