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