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

Breadcrumb

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

class ContainerCommandLoader

Loads commands from a PSR-11 container.

@author Robin Chalas <robin.chalas@gmail.com>

Hierarchy

  • class \Symfony\Component\Console\CommandLoader\ContainerCommandLoader implements \Symfony\Component\Console\CommandLoader\CommandLoaderInterface

Expanded class hierarchy of ContainerCommandLoader

1 file declares its use of ContainerCommandLoader
AddConsoleCommandPass.php in vendor/symfony/console/DependencyInjection/AddConsoleCommandPass.php

File

vendor/symfony/console/CommandLoader/ContainerCommandLoader.php, line 23

Namespace

Symfony\Component\Console\CommandLoader
View source
class ContainerCommandLoader implements CommandLoaderInterface {
    
    /**
     * @param array $commandMap An array with command names as keys and service ids as values
     */
    public function __construct(ContainerInterface $container, array $commandMap) {
    }
    public function get(string $name) : Command {
        if (!$this->has($name)) {
            throw new CommandNotFoundException(\sprintf('Command "%s" does not exist.', $name));
        }
        return $this->container
            ->get($this->commandMap[$name]);
    }
    public function has(string $name) : bool {
        return isset($this->commandMap[$name]) && $this->container
            ->has($this->commandMap[$name]);
    }
    public function getNames() : array {
        return array_keys($this->commandMap);
    }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title
ContainerCommandLoader::get public function Loads a command. Overrides CommandLoaderInterface::get
ContainerCommandLoader::getNames public function Overrides CommandLoaderInterface::getNames
ContainerCommandLoader::has public function Checks if a command exists. Overrides CommandLoaderInterface::has
ContainerCommandLoader::__construct public function

API Navigation

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