Collection for Commands.
Used by Applications to specify their console commands. CakePHP will use the mapped commands to construct and dispatch shell commands.
array<string,Cake\Console\ShellCake\Console\CommandInterface|string>Command list
Constructor
Add a command to the collection
Add multiple commands at once.
Automatically discover shell commands in CakePHP, the application and all plugins.
Implementation of Countable.
Auto-discover shell & commands from the named plugin.
Get the target for a command.
Implementation of IteratorAggregate.
Check whether the named shell exists in the collection.
Get the list of available command names.
Remove a command from the collection if it exists.
Resolve names based on existing commands
__construct(array<string,Cake\Console\ShellCake\Console\CommandInterface|string> $commands = [])
Constructor
array<string,Cake\Console\ShellCake\Console\CommandInterface|string> $commands optional The map of commands to add to the collection.
add(string $name, Cake\Console\CommandInterfaceCake\Console\Shell|string $command): $this
Add a command to the collection
string $name The name of the command you want to map.
Cake\Console\CommandInterfaceCake\Console\Shell|string $command The command to map. Can be a FQCN, Shell instance or CommandInterface instance.
$thisInvalidArgumentExceptionaddMany(array<string,Cake\Console\ShellCake\Console\CommandInterface|string> $commands): $this
Add multiple commands at once.
array<string,Cake\Console\ShellCake\Console\CommandInterface|string> $commands A map of command names => command classes/instances.
$thisautoDiscover(): array<string, string>
Automatically discover shell commands in CakePHP, the application and all plugins.
Commands will be located using filesystem conventions. Commands are discovered in the following order:
Commands defined in the application will overwrite commands with the same name provided by CakePHP.
array<string, string>count(): int
Implementation of Countable.
Get the number of commands in the collection.
intdiscoverPlugin(string $plugin): array<string, string>
Auto-discover shell & commands from the named plugin.
Discovered commands will have their names de-duplicated with existing commands in the collection. If a command is already defined in the collection and discovered in a plugin, only the long name (plugin.command) will be returned.
string $plugin The plugin to scan.
array<string, string>get(string $name): Cake\Console\CommandInterfaceCake\Console\Shell|string
Get the target for a command.
string $name The named shell.
Cake\Console\CommandInterfaceCake\Console\Shell|stringInvalidArgumentExceptiongetIterator(): Traversable
Implementation of IteratorAggregate.
Traversablehas(string $name): bool
Check whether the named shell exists in the collection.
string $name The named shell.
boolkeys(): array<string>
Get the list of available command names.
array<string>remove(string $name): $this
Remove a command from the collection if it exists.
string $name The named shell.
$thisresolveNames(array $input): array<string, string>
Resolve names based on existing commands
array $input The results of a CommandScanner operation.
array<string, string>Command list
array<string,Cake\Console\ShellCake\Console\CommandInterface|string>
© 2005–present The Cake Software Foundation, Inc.
Licensed under the MIT License.
CakePHP is a registered trademark of Cake Software Foundation, Inc.
We are not endorsed by or affiliated with CakePHP.
https://api.cakephp.org/4.4/class-Cake.Console.CommandCollection.html