Provide $useSource argument to the DownloaderInterface methods
parent
17d1abcec0
commit
50aa7ac607
|
@ -94,12 +94,14 @@ class DownloadManager
|
|||
if (!($preferSource && $sourceType) && $distType) {
|
||||
$downloader = $this->getDownloader($distType);
|
||||
$downloader->download(
|
||||
$package, $targetDir, $package->getDistUrl(), $package->getDistSha1Checksum()
|
||||
$package, $targetDir,
|
||||
$package->getDistUrl(), $package->getDistSha1Checksum(),
|
||||
$preferSource
|
||||
);
|
||||
$package->setInstallationSource('dist');
|
||||
} elseif ($sourceType) {
|
||||
$downloader = $this->getDownloader($sourceType);
|
||||
$downloader->download($package, $targetDir, $package->getSourceUrl());
|
||||
$downloader->download($package, $targetDir, $package->getSourceUrl(), $preferSource);
|
||||
$package->setInstallationSource('source');
|
||||
} else {
|
||||
throw new \InvalidArgumentException('Package should have dist or source specified');
|
||||
|
@ -135,9 +137,9 @@ class DownloadManager
|
|||
$downloader = $this->getDownloader($initialType);
|
||||
|
||||
if ($initialType === $targetType) {
|
||||
$downloader->update($initial, $target, $targetDir);
|
||||
$downloader->update($initial, $target, $targetDir, $useSource);
|
||||
} else {
|
||||
$downloader->remove($initial, $targetDir);
|
||||
$downloader->remove($initial, $targetDir, $useSource);
|
||||
$this->download($target, $targetDir, $useSource);
|
||||
}
|
||||
}
|
||||
|
@ -164,6 +166,6 @@ class DownloadManager
|
|||
$downloader = $this->getDownloader($package->getSourceType());
|
||||
}
|
||||
|
||||
$downloader->remove($package, $targetDir);
|
||||
$downloader->remove($package, $targetDir, $useSource);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,8 +28,9 @@ interface DownloaderInterface
|
|||
* @param string $path download path
|
||||
* @param string $url download url
|
||||
* @param string $checksum package checksum (for dists)
|
||||
* @param Boolean $useSource download as source
|
||||
*/
|
||||
function download(PackageInterface $package, $path, $url, $checksum = null);
|
||||
function download(PackageInterface $package, $path, $url, $checksum = null, $useSource = false);
|
||||
|
||||
/**
|
||||
* Updates specific package in specific folder from initial to target version.
|
||||
|
@ -37,14 +38,16 @@ interface DownloaderInterface
|
|||
* @param PackageInterface $initial initial package
|
||||
* @param PackageInterface $target updated package
|
||||
* @param string $path download path
|
||||
* @param Boolean $useSource download as source
|
||||
*/
|
||||
function update(PackageInterface $initial, PackageInterface $target, $path);
|
||||
function update(PackageInterface $initial, PackageInterface $target, $path, $useSource = false);
|
||||
|
||||
/**
|
||||
* Removes specific package from specific folder.
|
||||
*
|
||||
* @param PackageInterface $package package instance
|
||||
* @param string $path download path
|
||||
* @param Boolean $useSource download as source
|
||||
*/
|
||||
function remove(PackageInterface $package, $path);
|
||||
function remove(PackageInterface $package, $path, $useSource = false);
|
||||
}
|
||||
|
|
|
@ -58,7 +58,7 @@ class DownloadManagerTest extends \PHPUnit_Framework_TestCase
|
|||
$pearDownloader
|
||||
->expects($this->once())
|
||||
->method('download')
|
||||
->with($package, 'target_dir', 'dist_url', 'sha1');
|
||||
->with($package, 'target_dir', 'dist_url', 'sha1', false);
|
||||
|
||||
$manager = new DownloadManager();
|
||||
$manager->setDownloader('pear', $pearDownloader);
|
||||
|
@ -114,7 +114,7 @@ class DownloadManagerTest extends \PHPUnit_Framework_TestCase
|
|||
$pearDownloader
|
||||
->expects($this->once())
|
||||
->method('download')
|
||||
->with($package, 'target_dir', 'dist_url', 'sha1');
|
||||
->with($package, 'target_dir', 'dist_url', 'sha1', false);
|
||||
|
||||
$manager = new DownloadManager();
|
||||
$manager->setDownloader('pear', $pearDownloader);
|
||||
|
@ -148,7 +148,7 @@ class DownloadManagerTest extends \PHPUnit_Framework_TestCase
|
|||
$gitDownloader
|
||||
->expects($this->once())
|
||||
->method('download')
|
||||
->with($package, 'vendor/pkg', 'source_url');
|
||||
->with($package, 'vendor/pkg', 'source_url', false);
|
||||
|
||||
$manager = new DownloadManager();
|
||||
$manager->setDownloader('git', $gitDownloader);
|
||||
|
@ -182,7 +182,7 @@ class DownloadManagerTest extends \PHPUnit_Framework_TestCase
|
|||
$gitDownloader
|
||||
->expects($this->once())
|
||||
->method('download')
|
||||
->with($package, 'vendor/pkg', 'source_url');
|
||||
->with($package, 'vendor/pkg', 'source_url', true);
|
||||
|
||||
$manager = new DownloadManager();
|
||||
$manager->setDownloader('git', $gitDownloader);
|
||||
|
@ -221,7 +221,7 @@ class DownloadManagerTest extends \PHPUnit_Framework_TestCase
|
|||
$pearDownloader
|
||||
->expects($this->once())
|
||||
->method('download')
|
||||
->with($package, 'target_dir', 'dist_url', 'sha1');
|
||||
->with($package, 'target_dir', 'dist_url', 'sha1', true);
|
||||
|
||||
$manager = new DownloadManager();
|
||||
$manager->setDownloader('pear', $pearDownloader);
|
||||
|
@ -256,7 +256,7 @@ class DownloadManagerTest extends \PHPUnit_Framework_TestCase
|
|||
$gitDownloader
|
||||
->expects($this->once())
|
||||
->method('download')
|
||||
->with($package, 'vendor/pkg', 'source_url');
|
||||
->with($package, 'vendor/pkg', 'source_url', true);
|
||||
|
||||
$manager = new DownloadManager();
|
||||
$manager->setDownloader('git', $gitDownloader);
|
||||
|
@ -306,7 +306,7 @@ class DownloadManagerTest extends \PHPUnit_Framework_TestCase
|
|||
$pearDownloader
|
||||
->expects($this->once())
|
||||
->method('update')
|
||||
->with($initial, $target, 'vendor/bundles/FOS/UserBundle');
|
||||
->with($initial, $target, 'vendor/bundles/FOS/UserBundle', false);
|
||||
|
||||
$manager = new DownloadManager();
|
||||
$manager->setDownloader('pear', $pearDownloader);
|
||||
|
@ -336,7 +336,7 @@ class DownloadManagerTest extends \PHPUnit_Framework_TestCase
|
|||
$pearDownloader
|
||||
->expects($this->once())
|
||||
->method('remove')
|
||||
->with($initial, 'vendor/bundles/FOS/UserBundle');
|
||||
->with($initial, 'vendor/bundles/FOS/UserBundle', false);
|
||||
|
||||
$manager = $this->getMockBuilder('Composer\Downloader\DownloadManager')
|
||||
->setMethods(array('download'))
|
||||
|
@ -372,7 +372,7 @@ class DownloadManagerTest extends \PHPUnit_Framework_TestCase
|
|||
$svnDownloader
|
||||
->expects($this->once())
|
||||
->method('update')
|
||||
->with($initial, $target, 'vendor/pkg');
|
||||
->with($initial, $target, 'vendor/pkg', true);
|
||||
|
||||
$manager = new DownloadManager();
|
||||
$manager->setDownloader('svn', $svnDownloader);
|
||||
|
@ -402,7 +402,7 @@ class DownloadManagerTest extends \PHPUnit_Framework_TestCase
|
|||
$svnDownloader
|
||||
->expects($this->once())
|
||||
->method('remove')
|
||||
->with($initial, 'vendor/pkg');
|
||||
->with($initial, 'vendor/pkg', true);
|
||||
|
||||
$manager = $this->getMockBuilder('Composer\Downloader\DownloadManager')
|
||||
->setMethods(array('download'))
|
||||
|
|
Loading…
Reference in New Issue