Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Application.php

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\Console

Code

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;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal