X-Git-Url: http://www.aleph1.co.uk/gitweb/?a=blobdiff_plain;f=vendor%2Fdrupal-composer%2Fdrupal-scaffold%2Fsrc%2FFileFetcher.php;h=653e7f22f1a8bdb58f2d4ea30e8a5e5e8c162a3e;hb=0bf8d09d2542548982e81a441b1f16e75873a04f;hp=4435306bad4eaf420d4de37f30ab740d55ab8ef2;hpb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;p=yaffs-website
diff --git a/vendor/drupal-composer/drupal-scaffold/src/FileFetcher.php b/vendor/drupal-composer/drupal-scaffold/src/FileFetcher.php
index 4435306ba..653e7f22f 100644
--- a/vendor/drupal-composer/drupal-scaffold/src/FileFetcher.php
+++ b/vendor/drupal-composer/drupal-scaffold/src/FileFetcher.php
@@ -1,15 +1,14 @@
remoteFilesystem = $remoteFilesystem;
+ $this->io = $io;
$this->source = $source;
- $this->filenames = $filenames;
$this->fs = new Filesystem();
+ $this->progress = $progress;
}
- public function fetch($version, $destination) {
- array_walk($this->filenames, function ($filename) use ($version, $destination) {
- $url = $this->getUri($filename, $version);
- $this->fs->ensureDirectoryExists($destination . '/' . dirname($filename));
- $this->remoteFilesystem->copy($url, $url, $destination . '/' . $filename);
- });
+ /**
+ * Downloads all required files and writes it to the file system.
+ */
+ public function fetch($version, $destination, $override) {
+ foreach ($this->filenames as $sourceFilename => $filename) {
+ $target = "$destination/$filename";
+ if ($override || !file_exists($target)) {
+ $url = $this->getUri($sourceFilename, $version);
+ $this->fs->ensureDirectoryExists($destination . '/' . dirname($filename));
+ if ($this->progress) {
+ $this->io->writeError(" - $filename ($url): ", FALSE);
+ $this->remoteFilesystem->copy($url, $url, $target, $this->progress);
+ // Used to put a new line because the remote file system does not put
+ // one.
+ $this->io->writeError('');
+ }
+ else {
+ $this->remoteFilesystem->copy($url, $url, $target, $this->progress);
+ }
+ }
+ }
}
+ /**
+ * Set filenames.
+ */
+ public function setFilenames(array $filenames) {
+ $this->filenames = $filenames;
+ }
+
+ /**
+ * Replace filename and version in the source pattern with their values.
+ */
protected function getUri($filename, $version) {
$map = [
'{path}' => $filename,
- '{version}' => $version
+ '{version}' => $version,
];
return str_replace(array_keys($map), array_values($map), $this->source);
}