CommandRegistry
in package
Table of Contents
Properties
- $commands : array<string, string>
- Map of command names to service names
- $container : Container
- Container instance to load the commands
Methods
- __construct() : void
- Construct the registry with a container
- available() : array<string, string>
- Available commands
- execute() : void
- Execute the command by name and with the given argument vector
- executeWithVector() : void
- Execute the command by name and with the given argument vector
- has() : bool
- Does a command with the given name exist?
- load() : Command
- Loads a command by its name from the registry.
- readCommandsFromContainer() : void
- Register available commands in the registry
- register() : void
- Register a command with a service name
Properties
$commands
Map of command names to service names
protected
array<string, string>
$commands
= []
$container
Container instance to load the commands
private
Container
$container
Methods
__construct()
Construct the registry with a container
public
__construct(Container $container) : void
Parameters
- $container : Container
available()
Available commands
public
available() : array<string, string>
Return values
array<string, string>execute()
Execute the command by name and with the given argument vector
public
execute(string $commandName[, string $arguments = '' ][, CLImate|null $cli = null ][, bool $overrideGlobalState = false ]) : void
Parameters
- $commandName : string
- $arguments : string = ''
- $cli : CLImate|null = null
- $overrideGlobalState : bool = false
executeWithVector()
Execute the command by name and with the given argument vector
public
executeWithVector(string $commandName[, array<string|int, mixed> $argumentVector = [] ][, CLImate|null $cli = null ][, bool $overrideGlobalState = false ]) : void
Parameters
- $commandName : string
- $argumentVector : array<string|int, mixed> = []
- $cli : CLImate|null = null
- $overrideGlobalState : bool = false
has()
Does a command with the given name exist?
public
has(string $commandName) : bool
Parameters
- $commandName : string
Return values
boolload()
Loads a command by its name from the registry.
public
load(string $commandName) : Command
Parameters
- $commandName : string
-
The command name as it is registered in the container as a meta tag.
Return values
Command —Returns the command behind the given command name.
readCommandsFromContainer()
Register available commands in the registry
public
readCommandsFromContainer(Container $container) : void
Parameters
- $container : Container
register()
Register a command with a service name
public
register(string $commandName, string $serviceName) : void
Parameters
- $commandName : string
- $serviceName : string