Add drupal scaffold
This commit is contained in:
parent
6fa31ad086
commit
3e6a5cbed2
15 changed files with 2748 additions and 1 deletions
web/vendor/drupal-composer/drupal-scaffold/src
47
web/vendor/drupal-composer/drupal-scaffold/src/FileFetcher.php
vendored
Normal file
47
web/vendor/drupal-composer/drupal-scaffold/src/FileFetcher.php
vendored
Normal file
|
@ -0,0 +1,47 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \DrupalComposer\DrupalScaffold\FileFetcher.
|
||||
*/
|
||||
|
||||
namespace DrupalComposer\DrupalScaffold;
|
||||
|
||||
use Composer\Util\Filesystem;
|
||||
use Composer\Util\RemoteFilesystem;
|
||||
|
||||
class FileFetcher {
|
||||
|
||||
/**
|
||||
* @var \Composer\Util\RemoteFilesystem
|
||||
*/
|
||||
protected $remoteFilesystem;
|
||||
|
||||
protected $source;
|
||||
protected $filenames;
|
||||
protected $fs;
|
||||
|
||||
public function __construct(RemoteFilesystem $remoteFilesystem, $source, $filenames = []) {
|
||||
$this->remoteFilesystem = $remoteFilesystem;
|
||||
$this->source = $source;
|
||||
$this->filenames = $filenames;
|
||||
$this->fs = new Filesystem();
|
||||
}
|
||||
|
||||
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);
|
||||
});
|
||||
}
|
||||
|
||||
protected function getUri($filename, $version) {
|
||||
$map = [
|
||||
'{path}' => $filename,
|
||||
'{version}' => $version
|
||||
];
|
||||
return str_replace(array_keys($map), array_values($map), $this->source);
|
||||
}
|
||||
|
||||
}
|
Reference in a new issue