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

Breadcrumb

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

class FactoryCommandLoader

A simple command loader using factories to instantiate commands lazily.

@author Maxime Steinhausser <maxime.steinhausser@gmail.com>

Hierarchy

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

Expanded class hierarchy of FactoryCommandLoader

File

vendor/symfony/console/CommandLoader/FactoryCommandLoader.php, line 22

Namespace

Symfony\Component\Console\CommandLoader
View source
class FactoryCommandLoader implements CommandLoaderInterface {
    
    /**
     * @param callable[] $factories Indexed by command names
     */
    public function __construct(array $factories) {
    }
    public function has(string $name) : bool {
        return isset($this->factories[$name]);
    }
    public function get(string $name) : Command {
        if (!isset($this->factories[$name])) {
            throw new CommandNotFoundException(\sprintf('Command "%s" does not exist.', $name));
        }
        $factory = $this->factories[$name];
        return $factory();
    }
    public function getNames() : array {
        return array_keys($this->factories);
    }

}

Members

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

API Navigation

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