function Application::all
Gets the commands (registered in the given namespace if provided).
The array keys are the full names and the values the command instances.
Return value
Command[]
2 calls to Application::all()
- Application::complete in vendor/
symfony/ console/ Application.php - Adds suggestions to $suggestions for the current completion input (e.g. option or argument).
- Application::getNamespaces in vendor/
symfony/ console/ Application.php - Returns an array of all unique namespaces used by currently registered commands.
File
-
vendor/
symfony/ console/ Application.php, line 787
Class
- Application
- An Application is the container for a collection of commands.
Namespace
Symfony\Component\ConsoleCode
public function all(?string $namespace = null) : array {
$this->init();
if (null === $namespace) {
if (!$this->commandLoader) {
return $this->commands;
}
$commands = $this->commands;
foreach ($this->commandLoader
->getNames() as $name) {
if (!isset($commands[$name]) && $this->has($name)) {
$commands[$name] = $this->get($name);
}
}
return $commands;
}
$commands = [];
foreach ($this->commands as $name => $command) {
if ($namespace === $this->extractNamespace($name, substr_count($namespace, ':') + 1)) {
$commands[$name] = $command;
}
}
if ($this->commandLoader) {
foreach ($this->commandLoader
->getNames() as $name) {
if (!isset($commands[$name]) && $namespace === $this->extractNamespace($name, substr_count($namespace, ':') + 1) && $this->has($name)) {
$commands[$name] = $this->get($name);
}
}
}
return $commands;
}