|
@@ -14,42 +14,60 @@ namespace Composer\Installer;
|
|
|
|
|
|
use Composer\Downloader\DownloaderInterface;
|
|
use Composer\Downloader\DownloaderInterface;
|
|
use Composer\Package\PackageInterface;
|
|
use Composer\Package\PackageInterface;
|
|
|
|
+use Composer\Composer;
|
|
|
|
|
|
/**
|
|
/**
|
|
* @author Jordi Boggiano <j.boggiano@seld.be>
|
|
* @author Jordi Boggiano <j.boggiano@seld.be>
|
|
*/
|
|
*/
|
|
class LibraryInstaller implements InstallerInterface
|
|
class LibraryInstaller implements InstallerInterface
|
|
{
|
|
{
|
|
- protected $dir;
|
|
|
|
|
|
+ private $dir;
|
|
|
|
+ private $composer;
|
|
|
|
|
|
public function __construct($dir = 'vendor')
|
|
public function __construct($dir = 'vendor')
|
|
{
|
|
{
|
|
$this->dir = $dir;
|
|
$this->dir = $dir;
|
|
}
|
|
}
|
|
|
|
|
|
- public function install(PackageInterface $package, DownloaderInterface $downloader, $type)
|
|
|
|
|
|
+ public function setComposer(Composer $composer)
|
|
{
|
|
{
|
|
- if ($type === 'dist') {
|
|
|
|
- $downloader->download($package, $this->dir, $package->getDistUrl(), $package->getDistSha1Checksum());
|
|
|
|
- } elseif ($type === 'source') {
|
|
|
|
- $downloader->download($package, $this->dir, $package->getSourceUrl());
|
|
|
|
|
|
+ $this->composer = $composer;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public function install(PackageInterface $package)
|
|
|
|
+ {
|
|
|
|
+ if ($package->getDistType()) {
|
|
|
|
+
|
|
|
|
+ $this->composer->getDownloader($package->getDistType())->download(
|
|
|
|
+ $package, $this->dir, $package->getDistUrl(), $package->getDistSha1Checksum()
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ } elseif ($package->getSourceType()) {
|
|
|
|
+
|
|
|
|
+ $this->composer->getDownloader($package->getSourceType())->download(
|
|
|
|
+ $package, $this->dir, $package->getSourceUrl()
|
|
|
|
+ );
|
|
|
|
+
|
|
} else {
|
|
} else {
|
|
- throw new \InvalidArgumentException('Type must be one of (dist, source), '.$type.' given.');
|
|
|
|
|
|
+ throw new \InvalidArgumentException(
|
|
|
|
+ 'Type must be one of (dist, source), '.$type.' given.'
|
|
|
|
+ );
|
|
}
|
|
}
|
|
|
|
+
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
|
|
- public function isInstalled(PackageInterface $package, $downloader, $type)
|
|
|
|
|
|
+ public function isInstalled(PackageInterface $package)
|
|
{
|
|
{
|
|
// TODO: implement installation check
|
|
// TODO: implement installation check
|
|
}
|
|
}
|
|
|
|
|
|
- public function update(PackageInterface $package, $downloader, $type)
|
|
|
|
|
|
+ public function update(PackageInterface $package)
|
|
{
|
|
{
|
|
// TODO: implement package update
|
|
// TODO: implement package update
|
|
}
|
|
}
|
|
|
|
|
|
- public function remove(PackageInterface $package, $downloader, $type)
|
|
|
|
|
|
+ public function remove(PackageInterface $package)
|
|
{
|
|
{
|
|
// TODO: implement package removal
|
|
// TODO: implement package removal
|
|
}
|
|
}
|