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

Breadcrumb

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

function Application::get

Returns a registered command by name or alias.

Throws

CommandNotFoundException When given command name does not exist

2 calls to Application::get()
Application::all in vendor/symfony/console/Application.php
Gets the commands (registered in the given namespace if provided).
Application::find in vendor/symfony/console/Application.php
Finds a command by name or alias.

File

vendor/symfony/console/Application.php, line 574

Class

Application
An Application is the container for a collection of commands.

Namespace

Symfony\Component\Console

Code

public function get(string $name) : Command {
    $this->init();
    if (!$this->has($name)) {
        throw new CommandNotFoundException(\sprintf('The command "%s" does not exist.', $name));
    }
    // When the command has a different name than the one used at the command loader level
    if (!isset($this->commands[$name])) {
        throw new CommandNotFoundException(\sprintf('The "%s" command cannot be found because it is registered under multiple names. Make sure you don\'t set a different name via constructor or "setName()".', $name));
    }
    $command = $this->commands[$name];
    if ($this->wantHelps) {
        $this->wantHelps = false;
        $helpCommand = $this->get('help');
        $helpCommand->setCommand($command);
        return $helpCommand;
    }
    return $command;
}

API Navigation

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