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

Breadcrumb

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

function ConfigCommand::handleSingleValue

Parameters

array{callable, callable} $callbacks Validator and normalizer callbacks:

array<string> $values:

1 call to ConfigCommand::handleSingleValue()
ConfigCommand::execute in vendor/composer/composer/src/Composer/Command/ConfigCommand.php

File

vendor/composer/composer/src/Composer/Command/ConfigCommand.php, line 902

Class

ConfigCommand
@author Joshua Estes <Joshua.Estes@iostudio.com> @author Jordi Boggiano <j.boggiano@seld.be>

Namespace

Composer\Command

Code

protected function handleSingleValue(string $key, array $callbacks, array $values, string $method) : void {
    [
        $validator,
        $normalizer,
    ] = $callbacks;
    if (1 !== count($values)) {
        throw new \RuntimeException('You can only pass one value. Example: php composer.phar config process-timeout 300');
    }
    if (true !== ($validation = $validator($values[0]))) {
        throw new \RuntimeException(sprintf('"%s" is an invalid value' . ($validation ? ' (' . $validation . ')' : ''), $values[0]));
    }
    $normalizedValue = $normalizer($values[0]);
    if ($key === 'disable-tls') {
        if (!$normalizedValue && $this->config
            ->get('disable-tls')) {
            $this->getIO()
                ->writeError('<info>You are now running Composer with SSL/TLS protection enabled.</info>');
        }
        elseif ($normalizedValue && !$this->config
            ->get('disable-tls')) {
            $this->getIO()
                ->writeError('<warning>You are now running Composer with SSL/TLS protection disabled.</warning>');
        }
    }
    call_user_func([
        $this->configSource,
        $method,
    ], $key, $normalizedValue);
}

API Navigation

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