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

Breadcrumb

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

function Versions::setChannel

File

vendor/composer/composer/src/Composer/SelfUpdate/Versions.php, line 65

Class

Versions
@author Jordi Boggiano <j.boggiano@seld.be>

Namespace

Composer\SelfUpdate

Code

public function setChannel(string $channel, ?IOInterface $io = null) : void {
    if (!in_array($channel, self::CHANNELS, true)) {
        throw new \InvalidArgumentException('Invalid channel ' . $channel . ', must be one of: ' . implode(', ', self::CHANNELS));
    }
    $channelFile = $this->config
        ->get('home') . '/update-channel';
    $this->channel = $channel;
    // rewrite '2' and '1' channels to stable for future self-updates, but LTS ones like '2.2' remain pinned
    $storedChannel = Preg::isMatch('{^\\d+$}D', $channel) ? 'stable' : $channel;
    $previouslyStored = file_exists($channelFile) ? trim((string) file_get_contents($channelFile)) : null;
    file_put_contents($channelFile, $storedChannel . PHP_EOL);
    if ($io !== null && $previouslyStored !== $storedChannel) {
        $io->writeError('Storing "<info>' . $storedChannel . '</info>" as default update channel for the next self-update run.');
    }
}

API Navigation

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