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

Breadcrumb

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

function FileDownloader::getLocalChanges

@inheritDoc

Throws

\RuntimeException

Overrides ChangeReportInterface::getLocalChanges

File

vendor/composer/composer/src/Composer/Downloader/FileDownloader.php, line 490

Class

FileDownloader
Base downloader for files

Namespace

Composer\Downloader

Code

public function getLocalChanges(PackageInterface $package, string $path) : ?string {
    $prevIO = $this->io;
    $this->io = new NullIO();
    $this->io
        ->loadConfiguration($this->config);
    $e = null;
    $output = '';
    $targetDir = Filesystem::trimTrailingSlash($path);
    try {
        if (is_dir($targetDir . '_compare')) {
            $this->filesystem
                ->removeDirectory($targetDir . '_compare');
        }
        $promise = $this->download($package, $targetDir . '_compare', null, false);
        $promise->then(null, function ($ex) use (&$e) {
            $e = $ex;
        });
        $this->httpDownloader
            ->wait();
        if ($e !== null) {
            throw $e;
        }
        $promise = $this->install($package, $targetDir . '_compare', false);
        $promise->then(null, function ($ex) use (&$e) {
            $e = $ex;
        });
        $this->process
            ->wait();
        if ($e !== null) {
            throw $e;
        }
        $comparer = new Comparer();
        $comparer->setSource($targetDir . '_compare');
        $comparer->setUpdate($targetDir);
        $comparer->doCompare();
        $output = $comparer->getChangedAsString(true);
        $this->filesystem
            ->removeDirectory($targetDir . '_compare');
    } catch (\Exception $e) {
    }
    $this->io = $prevIO;
    if ($e !== null) {
        if ($this->io
            ->isDebug()) {
            throw $e;
        }
        return 'Failed to detect changes: [' . get_class($e) . '] ' . $e->getMessage();
    }
    $output = trim($output);
    return strlen($output) > 0 ? $output : null;
}

API Navigation

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