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

Breadcrumb

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

class LazyCommand

@author Nicolas Grekas <p@tchwork.com>

Hierarchy

  • class \Symfony\Component\Console\Command\Command
    • class \Symfony\Component\Console\Command\LazyCommand extends \Symfony\Component\Console\Command\Command

Expanded class hierarchy of LazyCommand

2 files declare their use of LazyCommand
AddConsoleCommandPass.php in vendor/symfony/console/DependencyInjection/AddConsoleCommandPass.php
Application.php in vendor/symfony/console/Application.php

File

vendor/symfony/console/Command/LazyCommand.php, line 27

Namespace

Symfony\Component\Console\Command
View source
final class LazyCommand extends Command {
    private \Closure|Command $command;
    public function __construct(string $name, array $aliases, string $description, bool $isHidden, \Closure $commandFactory, ?bool $isEnabled = true) {
        $this->setName($name)
            ->setAliases($aliases)
            ->setHidden($isHidden)
            ->setDescription($description);
        $this->command = $commandFactory;
    }
    public function ignoreValidationErrors() : void {
        $this->getCommand()
            ->ignoreValidationErrors();
    }
    public function setApplication(?Application $application) : void {
        if ($this->command instanceof parent) {
            $this->command
                ->setApplication($application);
        }
        parent::setApplication($application);
    }
    public function setHelperSet(HelperSet $helperSet) : void {
        if ($this->command instanceof parent) {
            $this->command
                ->setHelperSet($helperSet);
        }
        parent::setHelperSet($helperSet);
    }
    public function isEnabled() : bool {
        return $this->isEnabled ?? $this->getCommand()
            ->isEnabled();
    }
    public function run(InputInterface $input, OutputInterface $output) : int {
        return $this->getCommand()
            ->run($input, $output);
    }
    public function complete(CompletionInput $input, CompletionSuggestions $suggestions) : void {
        $this->getCommand()
            ->complete($input, $suggestions);
    }
    public function setCode(callable $code) : static {
        $this->getCommand()
            ->setCode($code);
        return $this;
    }
    
    /**
     * @internal
     */
    public function mergeApplicationDefinition(bool $mergeArgs = true) : void {
        $this->getCommand()
            ->mergeApplicationDefinition($mergeArgs);
    }
    public function setDefinition(array|InputDefinition $definition) : static {
        $this->getCommand()
            ->setDefinition($definition);
        return $this;
    }
    public function getDefinition() : InputDefinition {
        return $this->getCommand()
            ->getDefinition();
    }
    public function getNativeDefinition() : InputDefinition {
        return $this->getCommand()
            ->getNativeDefinition();
    }
    
    /**
     * @param array|\Closure(CompletionInput,CompletionSuggestions):list<string|Suggestion> $suggestedValues The values used for input completion
     */
    public function addArgument(string $name, ?int $mode = null, string $description = '', mixed $default = null, array|\Closure $suggestedValues = []) : static {
        $this->getCommand()
            ->addArgument($name, $mode, $description, $default, $suggestedValues);
        return $this;
    }
    
    /**
     * @param array|\Closure(CompletionInput,CompletionSuggestions):list<string|Suggestion> $suggestedValues The values used for input completion
     */
    public function addOption(string $name, string|array|null $shortcut = null, ?int $mode = null, string $description = '', mixed $default = null, array|\Closure $suggestedValues = []) : static {
        $this->getCommand()
            ->addOption($name, $shortcut, $mode, $description, $default, $suggestedValues);
        return $this;
    }
    public function setProcessTitle(string $title) : static {
        $this->getCommand()
            ->setProcessTitle($title);
        return $this;
    }
    public function setHelp(string $help) : static {
        $this->getCommand()
            ->setHelp($help);
        return $this;
    }
    public function getHelp() : string {
        return $this->getCommand()
            ->getHelp();
    }
    public function getProcessedHelp() : string {
        return $this->getCommand()
            ->getProcessedHelp();
    }
    public function getSynopsis(bool $short = false) : string {
        return $this->getCommand()
            ->getSynopsis($short);
    }
    public function addUsage(string $usage) : static {
        $this->getCommand()
            ->addUsage($usage);
        return $this;
    }
    public function getUsages() : array {
        return $this->getCommand()
            ->getUsages();
    }
    public function getHelper(string $name) : HelperInterface {
        return $this->getCommand()
            ->getHelper($name);
    }
    public function getCommand() : parent {
        if (!$this->command instanceof \Closure) {
            return $this->command;
        }
        $command = $this->command = ($this->command)();
        $command->setApplication($this->getApplication());
        if (null !== $this->getHelperSet()) {
            $command->setHelperSet($this->getHelperSet());
        }
        $command->setName($this->getName())
            ->setAliases($this->getAliases())
            ->setHidden($this->isHidden())
            ->setDescription($this->getDescription());
        // Will throw if the command is not correctly initialized.
        $command->getDefinition();
        return $command;
    }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title Overrides
Command::$aliases private property 1
Command::$application private property
Command::$code private property
Command::$definition private property
Command::$description private property 1
Command::$fullDefinition private property
Command::$help private property
Command::$helperSet private property
Command::$hidden private property
Command::$ignoreValidationErrors private property 2
Command::$name private property
Command::$processTitle private property
Command::$synopsis private property
Command::$usages private property
Command::configure protected function Configures the current command. 50
Command::execute protected function Executes the current command. 51
Command::FAILURE public constant
Command::getAliases public function Returns the aliases for the command.
Command::getApplication public function Gets the application instance for this command. 2
Command::getDefaultDescription public static function
Command::getDefaultName public static function
Command::getDescription public function Returns the description for the command.
Command::getHelperSet public function Gets the helper set. 1
Command::getName public function Returns the command name.
Command::initialize protected function Initializes the command after the input has been bound and before the input
is validated.
4
Command::interact protected function Interacts with the user. 5
Command::INVALID public constant
Command::isHidden public function
Command::setAliases public function Sets the aliases for the command.
Command::setDescription public function Sets the description for the command.
Command::setHidden public function
Command::setName public function Sets the name of the command.
Command::SUCCESS public constant
Command::validateName private function Validates a command name.
LazyCommand::$command private property
LazyCommand::addArgument public function Overrides Command::addArgument
LazyCommand::addOption public function Overrides Command::addOption
LazyCommand::addUsage public function Add a command usage example, it&#039;ll be prefixed with the command name. Overrides Command::addUsage
LazyCommand::complete public function Supplies suggestions when resolving possible completion options for input (e.g. option or argument). Overrides Command::complete
LazyCommand::getCommand public function
LazyCommand::getDefinition public function Gets the InputDefinition attached to this Command. Overrides Command::getDefinition
LazyCommand::getHelp public function Returns the help for the command. Overrides Command::getHelp
LazyCommand::getHelper public function Gets a helper instance by name. Overrides Command::getHelper
LazyCommand::getNativeDefinition public function Gets the InputDefinition to be used to create representations of this Command. Overrides Command::getNativeDefinition
LazyCommand::getProcessedHelp public function Returns the processed help for the command replacing the %command.name% and
%command.full_name% patterns with the real values dynamically.
Overrides Command::getProcessedHelp
LazyCommand::getSynopsis public function Returns the synopsis for the command. Overrides Command::getSynopsis
LazyCommand::getUsages public function Returns alternative usages of the command. Overrides Command::getUsages
LazyCommand::ignoreValidationErrors public function Ignores validation errors. Overrides Command::ignoreValidationErrors
LazyCommand::isEnabled public function Checks whether the command is enabled or not in the current environment. Overrides Command::isEnabled
LazyCommand::mergeApplicationDefinition public function @internal Overrides Command::mergeApplicationDefinition
LazyCommand::run public function Runs the command. Overrides Command::run
LazyCommand::setApplication public function Overrides Command::setApplication
LazyCommand::setCode public function Sets the code to execute when running this command. Overrides Command::setCode
LazyCommand::setDefinition public function Sets an array of argument and option instances. Overrides Command::setDefinition
LazyCommand::setHelp public function Sets the help for the command. Overrides Command::setHelp
LazyCommand::setHelperSet public function Overrides Command::setHelperSet
LazyCommand::setProcessTitle public function Sets the process title of the command. Overrides Command::setProcessTitle
LazyCommand::__construct public function Overrides Command::__construct

API Navigation

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