Final Class Yiisoft\Yii\Console\CommandLoader
| Inheritance | Yiisoft\Yii\Console\CommandLoader |
|---|---|
| Implements | Symfony\Component\Console\CommandLoader\CommandLoaderInterface |
Public Methods
Method Details
| public mixed __construct ( \Psr\Container\ContainerInterface $container, array $commandMap ) | ||
| $container | \Psr\Container\ContainerInterface | |
| $commandMap | array |
An array with command names as keys and service ids as values. |
public function __construct(private ContainerInterface $container, array $commandMap)
{
$this->setCommandMap($commandMap);
}
| public \Symfony\Component\Console\Command\Command get ( string $name ) | ||
| $name | string | |
public function get(string $name): Command
{
if (!$this->has($name)) {
throw new CommandNotFoundException(sprintf('Command "%s" does not exist.', $name));
}
$commandName = $this->commandMap[$name]['name'];
$commandAliases = $this->commandMap[$name]['aliases'];
$commandClass = $this->commandMap[$name]['class'];
$commandHidden = $this->commandMap[$name]['hidden'];
$description = $this->getCommandDescription($commandClass);
if ($description === null) {
return $this->getCommandInstance($name);
}
return new LazyCommand(
$commandName,
$commandAliases,
$description,
$commandHidden,
fn () => $this->getCommandInstance($name),
);
}
Signup or Login in order to comment.