5 * Contains \DrupalComposer\DrupalScaffold\FileFetcher.
8 namespace DrupalComposer\DrupalScaffold;
10 use Composer\Util\Filesystem;
11 use Composer\Util\RemoteFilesystem;
16 * @var \Composer\Util\RemoteFilesystem
18 protected $remoteFilesystem;
24 public function __construct(RemoteFilesystem $remoteFilesystem, $source, $filenames = []) {
25 $this->remoteFilesystem = $remoteFilesystem;
26 $this->source = $source;
27 $this->filenames = $filenames;
28 $this->fs = new Filesystem();
31 public function fetch($version, $destination) {
32 array_walk($this->filenames, function ($filename) use ($version, $destination) {
33 $url = $this->getUri($filename, $version);
34 $this->fs->ensureDirectoryExists($destination . '/' . dirname($filename));
35 $this->remoteFilesystem->copy($url, $url, $destination . '/' . $filename);
39 protected function getUri($filename, $version) {
41 '{path}' => $filename,
42 '{version}' => $version
44 return str_replace(array_keys($map), array_values($map), $this->source);