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

Breadcrumb

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

function LibraryInstaller::updateCode

@phpstan-return PromiseInterface<void|null>|null

Return value

PromiseInterface|null

1 call to LibraryInstaller::updateCode()
LibraryInstaller::update in vendor/composer/composer/src/Composer/Installer/LibraryInstaller.php
@inheritDoc

File

vendor/composer/composer/src/Composer/Installer/LibraryInstaller.php, line 288

Class

LibraryInstaller
Package installation manager.

Namespace

Composer\Installer

Code

protected function updateCode(PackageInterface $initial, PackageInterface $target) {
    $initialDownloadPath = $this->getInstallPath($initial);
    $targetDownloadPath = $this->getInstallPath($target);
    if ($targetDownloadPath !== $initialDownloadPath) {
        // if the target and initial dirs intersect, we force a remove + install
        // to avoid the rename wiping the target dir as part of the initial dir cleanup
        if (strpos($initialDownloadPath, $targetDownloadPath) === 0 || strpos($targetDownloadPath, $initialDownloadPath) === 0) {
            $promise = $this->removeCode($initial);
            if (!$promise instanceof PromiseInterface) {
                $promise = \React\Promise\resolve(null);
            }
            return $promise->then(function () use ($target) : PromiseInterface {
                $promise = $this->installCode($target);
                if ($promise instanceof PromiseInterface) {
                    return $promise;
                }
                return \React\Promise\resolve(null);
            });
        }
        $this->filesystem
            ->rename($initialDownloadPath, $targetDownloadPath);
    }
    return $this->getDownloadManager()
        ->update($initial, $target, $targetDownloadPath);
}

API Navigation

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