Application

Extends AbstractApplication

Base application class for a Joomla! command line application.

since

2.0.0

package

Joomla Framework

Methods

__construct

Class constructor.

__construct(\Symfony\Component\Console\Input\InputInterface input = null, \Symfony\Component\Console\Output\OutputInterface output = null, \Joomla\Registry\Registry config = null) : 
since

2.0.0

Arguments

input

InputInterface|nullAn 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

OutputInterface|nullAn 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.

config

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

LogicException

Arguments

command

AbstractCommandThe command to add to the application.

Response

AbstractCommand

close

Method to close the application.

close( code) : 
inherited
since

1.0.0

Arguments

code

intThe exit code (optional; default is 0).

Response

void

configureIO

Configures the console input and output instances for the process.

configureIO() : 
since

2.0.0

Response

void

dispatchEvent

Dispatches an application event if the dispatcher has been set.

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

2.0.0

Arguments

eventName

stringThe event to dispatch.

event

EventInterface|nullThe event object.

Response

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

doExecute

Method to run the application routines.

doExecute() : 
since

2.0.0

throws

Throwable

Response

intThe exit code for the application

doRenderThrowable

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

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

2.0.0

Arguments

throwable

ThrowableThe Throwable object to render the message for.

output

OutputInterfaceThe output object to send the message to.

Response

void

execute

Execute the application.

execute() : 
since

2.0.0

throws

Throwable

Response

void

extractAllNamespaces

Returns all namespaces of the command name.

extractAllNamespaces( name) : string||string|int
since

2.0.0

Arguments

name

stringThe full name of the command

Response

array<string|int, string>

extractNamespace

Returns the namespace part of the command name.

extractNamespace( name, int limit = null) : 
since

2.0.0

Arguments

name

stringThe command name to process

limit

int|nullThe maximum number of parts of the namespace

Response

string

findNamespace

Finds a registered namespace by a name.

findNamespace( namespace) : 
since

2.0.0

throws

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( key,  default = null) : 
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( namespace = '') : \Joomla\Console\Command\AbstractCommand||string|int
since

2.0.0

Arguments

namespace

stringAn optional command namespace to filter by.

Response

array<string|int, AbstractCommand>

getCommand

Returns a registered command by name or alias.

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

2.0.0

throws

CommandNotFoundException

Arguments

name

stringThe command name or alias

Response

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

InputInterfaceThe input to read the argument from

Response

string|null

getCommands

Get the registered commands.

getCommands() : \Joomla\Console\Command\AbstractCommand||string|int

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

array<string|int, AbstractCommand>

getConsoleInput

Get the console input handler.

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

2.0.0

Response

InputInterface

getConsoleOutput

Get the console output handler.

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

2.0.0

Response

OutputInterface

getDefaultCommands

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

getDefaultCommands() : \Joomla\Console\Command\AbstractCommand||string|int
since

2.0.0

Response

array<string|int, AbstractCommand>

getDefaultHelperSet

Builds the default helper set.

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

2.0.0

Response

HelperSet

getDefaultInputDefinition

Builds the default input definition.

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

2.0.0

Response

InputDefinition

getDefinition

Gets the InputDefinition related to this Application.

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

2.0.0

Response

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

DispatcherInterface

getHelperSet

Get the helper set associated with the application.

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

Response

HelperSet

getLogger

Get the logger.

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

1.0.0

Response

LoggerInterface

getLongVersion

Get the long version string for the application.

getLongVersion() : 

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

2.0.0

Response

string

getNamespaces

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

getNamespaces() : string||string|int

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

since

2.0.0

Response

array<string|int, string>

getVersion

Get the version of the application.

getVersion() : 
since

2.0.0

Response

string

hasCommand

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

hasCommand( name) : 
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() : 
since

2.0.0

Response

void

initialise

Custom initialisation method.

initialise() : 
since

2.0.0

Response

void

renderThrowable

Renders an error message for a Throwable object

renderThrowable(\Throwable throwable) : 
since

2.0.0

Arguments

throwable

ThrowableThe Throwable object to render the message for.

Response

void

runCommand

Run the given command.

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

2.0.0

throws

Throwable

Arguments

command

AbstractCommandThe command to run.

input

InputInterfaceThe input to inject into the command.

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( key,  value = null) : 
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( autoExit) : 
since

2.0.0

Arguments

autoExit

boolThe auto exit state.

Response

void

setCatchThrowables

Set whether the application should catch Throwables.

setCatchThrowables( catchThrowables) : 
since

2.0.0

Arguments

catchThrowables

boolThe catch Throwables state.

Response

void

setCommandLoader

Set the command loader.

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

2.0.0

Arguments

loader

LoaderInterfaceThe new command loader.

Response

void

setConfiguration

Sets the configuration for the application.

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

1.0.0

Arguments

config

RegistryA registry object holding the configuration.

Response

$this

setDispatcher

Set the dispatcher to use.

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

1.2.0

Arguments

dispatcher

DispatcherInterfaceThe dispatcher to use.

Response

$this

setHelperSet

Set the application's helper set.

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

2.0.0

Arguments

helperSet

HelperSetThe new HelperSet.

Response

void

setName

Set the name of the application.

setName( name) : 
since

2.0.0

Arguments

name

stringThe new application name.

Response

void

setVersion

Set the version of the application.

setVersion( version) : 
since

2.0.0

Arguments

version

stringThe new application version.

Response

void

shouldAutoExit

Get the application's auto exit state.

shouldAutoExit() : 
since

2.0.0

Response

bool

shouldCatchThrowables

Get the application's catch Throwables state.

shouldCatchThrowables() : 
since

2.0.0

Response

bool

splitStringByWidth

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

splitStringByWidth( string,  width) : string||string|int
since

2.0.0

Arguments

string

stringThe string to split.

width

intThe maximum width of the output.

Response

array<string|int, string>

Properties

dispatcher

Event Dispatcher

inherited
since

1.2.0

Type(s)

DispatcherInterface|null

config

The application configuration object.

inherited
since

1.0.0

Type(s)

Registry

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)

array<string|int, AbstractCommand>

commandLoader

The command loader.

since

2.0.0

Type(s)

LoaderInterface|null

consoleInput

Console input handler.

since

2.0.0

Type(s)

InputInterface

consoleOutput

Console output handler.

since

2.0.0

Type(s)

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)

InputDefinition|null

helperSet

The application helper set.

since

2.0.0

Type(s)

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)

AbstractCommand|null

terminal

The console terminal helper.

since

2.0.0

Type(s)

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