class CommandManager (View source)

A helper for CLI Commands

Properties

protected Command[] $availableCommands
protected array $shortCommandIdentifiers
protected Bootstrap $bootstrap
protected ObjectManagerInterface $objectManager

Methods

void
injectObjectManager(ObjectManagerInterface $objectManager)

No description

void
injectBootstrap(Bootstrap $bootstrap)

No description

array
getAvailableCommands()

Returns an array of all commands

getCommandByIdentifier(string $commandIdentifier)

Returns a Command that matches the given identifier.

array
getCommandsByIdentifier(string $commandIdentifier)

Returns an array of Commands that matches the given identifier.

string
getShortestIdentifierForCommand(Command $command)

Returns the shortest, non-ambiguous command identifier for the given command

array
getShortCommandIdentifiers()

Returns an array that contains all available command identifiers and their shortest non-ambiguous alias

bool
commandMatchesIdentifier(Command $command, string $commandIdentifier)

Returns true if the specified command identifier matches the identifier of the specified command.

array
getCommandMethodParameters(string $controllerObjectName, string $commandMethodName)

Get the possible parameters for the command specified by CommandController and method name.

static array

Details

void injectObjectManager(ObjectManagerInterface $objectManager)

No description

Parameters

ObjectManagerInterface $objectManager

Return Value

void

void injectBootstrap(Bootstrap $bootstrap)

No description

Parameters

Bootstrap $bootstrap

Return Value

void

array getAvailableCommands()

Returns an array of all commands

Return Value

array

Command getCommandByIdentifier(string $commandIdentifier)

Returns a Command that matches the given identifier.

If no Command could be found a CommandNotFoundException is thrown If more than one Command matches an AmbiguousCommandIdentifierException is thrown that contains the matched Commands

Parameters

string $commandIdentifier

command identifier in the format foo:bar:baz

Return Value

Command

Exceptions

NoSuchCommandException
AmbiguousCommandIdentifierException

array getCommandsByIdentifier(string $commandIdentifier)

Returns an array of Commands that matches the given identifier.

If no Command could be found, an empty array is returned

Parameters

string $commandIdentifier

command identifier in the format foo:bar:baz

Return Value

array

string getShortestIdentifierForCommand(Command $command)

Returns the shortest, non-ambiguous command identifier for the given command

Parameters

Command $command

The command

Return Value

string

The shortest possible command identifier

protected array getShortCommandIdentifiers()

Returns an array that contains all available command identifiers and their shortest non-ambiguous alias

Return Value

array

in the format array('full.command:identifier1' => 'alias1', 'full.command:identifier2' => 'alias2')

protected bool commandMatchesIdentifier(Command $command, string $commandIdentifier)

Returns true if the specified command identifier matches the identifier of the specified command.

This is the case, if

  • the identifiers are the same
  • if at least the last two command parts match (case sensitive)
  • if only the package key is specified and matches the commands package key (case insensitive) or
  • if the commandIdentifier matches the second command part (CommandController name, case insensitive) The first part (package key) can be reduced to the last subpackage, as long as the result is unambiguous.

Parameters

Command $command
string $commandIdentifier

command identifier in the format foo:bar:baz (all lower case)

Return Value

bool

true if the specified command identifier matches this commands identifier

array getCommandMethodParameters(string $controllerObjectName, string $commandMethodName)

Get the possible parameters for the command specified by CommandController and method name.

Parameters

string $controllerObjectName
string $commandMethodName

Return Value

array

static array getCommandControllerMethodArguments(ObjectManagerInterface $objectManager)

No description

Parameters

ObjectManagerInterface $objectManager

Return Value

array

Array of method arguments per controller and method.