Create a command from dca.

@param string $commandName The name of the command to parse.
@param array  $commandDca  The chunk from the DCA containing the command specification.

@return CommandInterface
547018
protected function createCommand($commandName, array $commandDca)
    {

        $command = $this->createCommandInstance($commandName, $commandDca);
        $command->setName($commandName);

        $parameters = $command->getParameters();

        if (isset($commandDca['href'])) {
            \parse_str($commandDca['href'], $queryParameters);
            foreach ($queryParameters as $name => $value) {
                $parameters[$name] = $value;
            }
            unset($commandDca['href']);
        }

        if (isset($commandDca['parameters'])) {
            foreach ($commandDca['parameters'] as $name => $value) {
                $parameters[$name] = $value;
            }
            unset($commandDca['parameters']);
        }

        if (isset($commandDca['label'])) {
            $lang = $commandDca['label'];

            if (\is_array($lang)) {
                $label       = \reset($lang);
                $description = \next($lang);

                $command->setDescription($description);
            } else {
                $label = $lang;
            }

            $command->setLabel($label);

            unset($commandDca['label']);
        }

        if (isset($commandDca['description'])) {
            $command->setDescription($commandDca['description']);

            unset($commandDca['description']);
        }

        // Callback is transformed into event in parseCallbacks().
        unset($commandDca['button_callback']);

        if (\count($commandDca)) {
            $extra = $command->getExtra();

            foreach ($commandDca as $name => $value) {
                $extra[$name] = $value;
            }
        }

        return $command;
    }
1155503
private function getManagerFromDca(DataContainer $dc): ManagerInterface
    {
        return $this->registry->get($GLOBALS['TL_DCA'][$dc->table]['fields'][$dc->field]['eval']['tagsManager']);
    }
852357
protected function getCommandConfig($commandKey)
    {
        if (isset($this->configsPerCommandKey[$commandKey])) {
            return $this->configsPerCommandKey[$commandKey];
        }
        $config = new Config($this->config->get('default')->toArray(), true);
        if ($this->config->__isset($commandKey)) {
            $commandConfig = $this->config->get($commandKey);
            $config->merge($commandConfig);
        }
        $this->configsPerCommandKey[$commandKey] = $config;
        return $config;
    }
971779
public function getHandlerForCommand($commandName)
    {
        if (!isset($this->commandToServiceId[$commandName])) {
            throw MissingHandlerException::forCommand($commandName);
        }

        return $this->container->get($this->commandToServiceId[$commandName]);
    }
1272141
public function getCommand($commandAlias)
    {
        if (!array_key_exists($commandAlias, $this->commands)) {
            throw new CommandException(sprintf('The command "%s" is not registered', $commandAlias));
        }

        return $this->commands[$commandAlias];
    }
387792
public function callCommand(string $command, array $arguments = [])
    {
        $newCommand = $this->getApplication()->find($command);

        $arguments['command'] = $command;

        return $newCommand->run(new ArrayInput($arguments), $this->getOutput());
    }
1321285
protected function showCommandHelp($commandName)
    {
        $command = $this->app->getCommand($commandName);

        if (!$command) {
            $this->output->writeln("<red>Unknown command:</red> {$commandName}");
            return;
        }

        if ($command->getDescription()) {
            $this->output->writeln("<yellow>Description:</yellow>");
            $this->output->writeln("  {$command->getDescription()}");
            $this->output->newline();
        }

        $this->output->writeln("<yellow>Usage:</yellow>");
        $this->output->writeln("  {$command->getUsage()}");
    }
597331
public function build(string $className): interfaces\commands\Command
    {
        $params = is_subclass_of($className, interfaces\commands\ExecutableCommand::class) ? [$this->bus] : [];

        /** @var interfaces\commands\Command $command */
        $command = \Yii::createObject($className, $params);

        $this->prepareCommand($command);

        return $command;
    }
681418
public function addCommand(CommandInterface $command, CommandInterface $before = null)
    {
        $hash = \spl_object_hash($command);

        if ($before) {
            $beforeHash = \spl_object_hash($before);

            if (isset($this->commands[$beforeHash])) {
                $hashes   = \array_keys($this->commands);
                $position = \array_search($beforeHash, $hashes);

                $this->commands = \array_merge(
                    \array_slice($this->commands, 0, $position),
                    [$hash => $command],
                    \array_slice($this->commands, $position)
                );
            } else {
                throw new DcGeneralInvalidArgumentException(
                    \sprintf(
                        'Command %s not contained command collection - can not add %s after it.',
                        $before->getName(),
                        $command->getName()
                    )
                );
            }
        } else {
            $this->commands[$hash] = $command;
        }

        return $this;
    }
588494
public function getHandlerForCommand($commandName)
    {
        if (!isset($this->commandToKeyMap[$commandName])) {
            throw MissingHandlerException::forCommand($commandName);
        }

        $key = $this->commandToKeyMap[$commandName];

        return $this->container[$key];
    }
666681
public function addCommand($command, $config = array())
    {
        if (!($command instanceof KControllerToolbarCommandInterface)) {
            $command = $this->getCommand($command, $config);
        }

        //Set the command parent
        $command->setParent($this);

        $this->_commands[$command->getName()] = $command;
        return $command;
    }
70139
public function getCommand($commandName)
    {
        $command = '';
        $possible = array();

        foreach ($this->commands as $values) {
            $command = $values['command'];

            if (preg_match("#" . $command . "#", $commandName)) {
                $possible[] = $values;
            }
        }

        if (sizeof($possible) == 1) {
            return $possible[0];
        }

        if (sizeof($possible)) {
            $index = 0;
            if (isset($this->commandsRuns[$command])) {
                if (sizeof($possible) <= $this->commandsRuns[$command]) {
                    $this->commandsRuns[$command] = 0;
                }

                $index = $this->commandsRuns[$command];
            }

            return $possible[$index];
        }

        return false;
    }
852481
public static function getCommand($command)
    {
        if (!is_string($command) || strlen($command) < 1) {
            throw new BadMethodCallException('Parameter command is not a valid string');
        }
        $instance = self::getInstance();
        
        if (!isset($instance->commands[$command])) {
            throw new BadMethodCallException('Command "' . $command . '" is not a registered command');
        }
        
        return $instance->commands[$command];
    }
1251785
public function createCommand($event) {
        if (!empty($this->commands[$event->name])) {
            if (is_callable($this->condition) && call_user_func($this->condition, $this->owner) === false) {
                return;
            }
            $class = $this->commands[$event->name];
            $command = new $class();
            if (($command instanceof CommandInterface) === false) {
                throw new InvalidParamException('Class name [' . get_class($class) . '] provided in "commands" param MUST implement the jlorente\command\base\CommandInterface interface');
            }
            $command->setReceiver($this->owner);
            CommandMapper::map($command);
        }
    }
1328667
public static function parse(array $commands)
    {
        $cli = array();

        parse_str(implode('&', array_slice($commands, 1)), $cli);

        $command = current(array_keys((array)$cli, ''));

        if (Str::contains($command, ':')) {

            list($controller, $action) = explode(':', $command);

            $cli['controller'] = $controller;
            $cli['action'] = $action;
        }

        return $cli;
    }
995247
public static function make( $cmd, $params )
	{
		if ( !is_array( $params ) )
		{
			$params = array( $params );
		}
		
		$forge = new static;
		
		if ( !method_exists( $forge, $cmd ) )
		{
			throw new CCException( "CCForge_Php - Command could not be found." );
		}
		
		return call_user_func_array( array( $forge, $cmd ), $params );
	}
590924
private function createCommandDefinition($id, $connectionId, $class, $serverName, $command)
    {
        $commandDefinition = new DefinitionDecorator($id);
        $commandDefinition->setClass($class);
        $commandDefinition->setLazy(true);
        $commandDefinition->replaceArgument(0, new Reference($connectionId));
        $commandDefinition->addTag('nanbando.server_command', ['server' => $serverName, 'command' => $command]);

        return $commandDefinition;
    }