2012-03-03 05:35:40 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This file is part of Composer.
|
|
|
|
*
|
|
|
|
* (c) Nils Adermann <naderman@naderman.de>
|
|
|
|
* Jordi Boggiano <j.boggiano@seld.be>
|
|
|
|
*
|
|
|
|
* For the full copyright and license information, please view the LICENSE
|
|
|
|
* file that was distributed with this source code.
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace Composer;
|
|
|
|
|
|
|
|
use Composer\Autoload\AutoloadGenerator;
|
|
|
|
use Composer\DependencyResolver\DefaultPolicy;
|
|
|
|
use Composer\DependencyResolver\Operation\UpdateOperation;
|
|
|
|
use Composer\DependencyResolver\Pool;
|
|
|
|
use Composer\DependencyResolver\Request;
|
|
|
|
use Composer\DependencyResolver\Solver;
|
2012-03-18 21:43:07 +00:00
|
|
|
use Composer\DependencyResolver\SolverProblemsException;
|
2012-03-05 23:48:07 +00:00
|
|
|
use Composer\Downloader\DownloadManager;
|
|
|
|
use Composer\Installer\InstallationManager;
|
2012-03-03 05:35:40 +00:00
|
|
|
use Composer\IO\IOInterface;
|
|
|
|
use Composer\Package\AliasPackage;
|
|
|
|
use Composer\Package\Link;
|
|
|
|
use Composer\Package\LinkConstraint\VersionConstraint;
|
2012-03-05 23:48:07 +00:00
|
|
|
use Composer\Package\Locker;
|
2012-03-03 05:35:40 +00:00
|
|
|
use Composer\Package\PackageInterface;
|
|
|
|
use Composer\Repository\CompositeRepository;
|
|
|
|
use Composer\Repository\PlatformRepository;
|
|
|
|
use Composer\Repository\RepositoryInterface;
|
2012-03-05 23:48:07 +00:00
|
|
|
use Composer\Repository\RepositoryManager;
|
2012-03-03 05:35:40 +00:00
|
|
|
use Composer\Script\EventDispatcher;
|
|
|
|
use Composer\Script\ScriptEvents;
|
|
|
|
|
2012-03-10 00:16:37 +00:00
|
|
|
/**
|
|
|
|
* @author Jordi Boggiano <j.boggiano@seld.be>
|
|
|
|
* @author Beau Simensen <beau@dflydev.com>
|
|
|
|
* @author Konstantin Kudryashov <ever.zet@gmail.com>
|
|
|
|
*/
|
2012-03-06 23:30:18 +00:00
|
|
|
class Installer
|
2012-03-03 05:35:40 +00:00
|
|
|
{
|
|
|
|
/**
|
2012-03-05 23:48:07 +00:00
|
|
|
* @var IOInterface
|
|
|
|
*/
|
|
|
|
protected $io;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var PackageInterface
|
|
|
|
*/
|
|
|
|
protected $package;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var DownloadManager
|
|
|
|
*/
|
|
|
|
protected $downloadManager;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var RepositoryManager
|
|
|
|
*/
|
|
|
|
protected $repositoryManager;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var Locker
|
|
|
|
*/
|
|
|
|
protected $locker;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var InstallationManager
|
|
|
|
*/
|
|
|
|
protected $installationManager;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var EventDispatcher
|
|
|
|
*/
|
|
|
|
protected $eventDispatcher;
|
|
|
|
|
2012-03-10 18:56:15 +00:00
|
|
|
protected $preferSource = false;
|
2012-04-14 09:55:57 +00:00
|
|
|
protected $devMode = false;
|
2012-03-10 18:56:15 +00:00
|
|
|
protected $dryRun = false;
|
|
|
|
protected $verbose = false;
|
|
|
|
protected $update = false;
|
2012-03-10 17:08:36 +00:00
|
|
|
|
2012-04-15 15:44:47 +00:00
|
|
|
/**
|
|
|
|
* @var array
|
|
|
|
*/
|
|
|
|
protected $suggestedPackages;
|
|
|
|
|
2012-03-10 17:08:36 +00:00
|
|
|
/**
|
|
|
|
* @var RepositoryInterface
|
|
|
|
*/
|
|
|
|
protected $additionalInstalledRepository;
|
|
|
|
|
2012-03-05 23:48:07 +00:00
|
|
|
/**
|
|
|
|
* Constructor
|
2012-03-10 00:16:37 +00:00
|
|
|
*
|
2012-03-03 05:35:40 +00:00
|
|
|
* @param IOInterface $io
|
2012-03-05 23:48:07 +00:00
|
|
|
* @param PackageInterface $package
|
|
|
|
* @param DownloadManager $downloadManager
|
|
|
|
* @param RepositoryManager $repositoryManager
|
|
|
|
* @param Locker $locker
|
|
|
|
* @param InstallationManager $installationManager
|
2012-03-03 05:35:40 +00:00
|
|
|
* @param EventDispatcher $eventDispatcher
|
2012-03-05 23:48:07 +00:00
|
|
|
*/
|
|
|
|
public function __construct(IOInterface $io, PackageInterface $package, DownloadManager $downloadManager, RepositoryManager $repositoryManager, Locker $locker, InstallationManager $installationManager, EventDispatcher $eventDispatcher)
|
|
|
|
{
|
|
|
|
$this->io = $io;
|
|
|
|
$this->package = $package;
|
|
|
|
$this->downloadManager = $downloadManager;
|
|
|
|
$this->repositoryManager = $repositoryManager;
|
|
|
|
$this->locker = $locker;
|
|
|
|
$this->installationManager = $installationManager;
|
|
|
|
$this->eventDispatcher = $eventDispatcher;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Run installation (or update)
|
2012-03-03 05:35:40 +00:00
|
|
|
*/
|
2012-03-10 17:08:36 +00:00
|
|
|
public function run()
|
2012-03-03 05:35:40 +00:00
|
|
|
{
|
2012-03-10 17:08:36 +00:00
|
|
|
if ($this->dryRun) {
|
|
|
|
$this->verbose = true;
|
2012-03-03 05:35:40 +00:00
|
|
|
}
|
|
|
|
|
2012-03-10 17:08:36 +00:00
|
|
|
if ($this->preferSource) {
|
2012-03-05 23:48:07 +00:00
|
|
|
$this->downloadManager->setPreferSource(true);
|
2012-03-03 05:35:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// create installed repo, this contains all local packages + platform packages (php & extensions)
|
2012-04-14 13:45:25 +00:00
|
|
|
$repos = array_merge($this->repositoryManager->getLocalRepositories(), array(new PlatformRepository()));
|
|
|
|
$installedRepo = new CompositeRepository($repos);
|
2012-03-10 17:08:36 +00:00
|
|
|
if ($this->additionalInstalledRepository) {
|
|
|
|
$installedRepo->addRepository($this->additionalInstalledRepository);
|
2012-03-03 05:35:40 +00:00
|
|
|
}
|
|
|
|
|
2012-04-14 13:45:25 +00:00
|
|
|
$aliases = $this->aliasPackages();
|
2012-03-03 05:35:40 +00:00
|
|
|
|
2012-03-10 17:08:36 +00:00
|
|
|
if (!$this->dryRun) {
|
2012-04-14 13:45:25 +00:00
|
|
|
// dispatch pre event
|
2012-03-10 17:08:36 +00:00
|
|
|
$eventName = $this->update ? ScriptEvents::PRE_UPDATE_CMD : ScriptEvents::PRE_INSTALL_CMD;
|
2012-03-05 23:48:07 +00:00
|
|
|
$this->eventDispatcher->dispatchCommandEvent($eventName);
|
2012-03-03 05:35:40 +00:00
|
|
|
}
|
|
|
|
|
2012-04-15 15:44:47 +00:00
|
|
|
$this->suggestedPackages = array();
|
2012-04-15 17:05:16 +00:00
|
|
|
if (!$this->doInstall($this->repositoryManager->getLocalRepository(), $installedRepo, $aliases)) {
|
2012-04-15 15:44:47 +00:00
|
|
|
return false;
|
|
|
|
}
|
2012-04-14 13:45:25 +00:00
|
|
|
if ($this->devMode) {
|
2012-04-15 17:05:16 +00:00
|
|
|
if (!$this->doInstall($this->repositoryManager->getLocalDevRepository(), $installedRepo, $aliases, true)) {
|
2012-04-15 15:44:47 +00:00
|
|
|
return false;
|
|
|
|
}
|
2012-04-14 13:45:25 +00:00
|
|
|
}
|
|
|
|
|
2012-04-19 19:55:35 +00:00
|
|
|
// output suggestions
|
2012-04-15 15:44:47 +00:00
|
|
|
foreach ($this->suggestedPackages as $suggestion) {
|
2012-04-14 13:45:25 +00:00
|
|
|
$this->io->write($suggestion['source'].' suggests installing '.$suggestion['target'].' ('.$suggestion['reason'].')');
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!$this->dryRun) {
|
|
|
|
// write lock
|
|
|
|
if ($this->update || !$this->locker->isLocked()) {
|
|
|
|
$updatedLock = $this->locker->setLockData(
|
|
|
|
$this->repositoryManager->getLocalRepository()->getPackages(),
|
2012-04-15 17:05:50 +00:00
|
|
|
$this->devMode ? $this->repositoryManager->getLocalDevRepository()->getPackages() : null,
|
2012-04-14 13:45:25 +00:00
|
|
|
$aliases
|
|
|
|
);
|
|
|
|
if ($updatedLock) {
|
|
|
|
$this->io->write('<info>Writing lock file</info>');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// write autoloader
|
|
|
|
$this->io->write('<info>Generating autoload files</info>');
|
|
|
|
$generator = new AutoloadGenerator;
|
|
|
|
$localRepos = new CompositeRepository($this->repositoryManager->getLocalRepositories());
|
2012-04-19 19:55:35 +00:00
|
|
|
$generator->dump($localRepos, $this->package, $this->installationManager, $this->installationManager->getVendorPath(), true);
|
2012-04-14 13:45:25 +00:00
|
|
|
|
|
|
|
// dispatch post event
|
|
|
|
$eventName = $this->update ? ScriptEvents::POST_UPDATE_CMD : ScriptEvents::POST_INSTALL_CMD;
|
|
|
|
$this->eventDispatcher->dispatchCommandEvent($eventName);
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-04-15 17:05:16 +00:00
|
|
|
protected function doInstall($localRepo, $installedRepo, $aliases, $devMode = false)
|
2012-04-14 13:45:25 +00:00
|
|
|
{
|
2012-04-15 17:05:16 +00:00
|
|
|
// creating repository pool
|
|
|
|
$pool = new Pool;
|
|
|
|
$pool->addRepository($installedRepo);
|
|
|
|
foreach ($this->repositoryManager->getRepositories() as $repository) {
|
|
|
|
$pool->addRepository($repository);
|
|
|
|
}
|
|
|
|
|
2012-03-03 05:35:40 +00:00
|
|
|
// creating requirements request
|
|
|
|
$installFromLock = false;
|
|
|
|
$request = new Request($pool);
|
2012-03-10 17:08:36 +00:00
|
|
|
if ($this->update) {
|
2012-04-14 13:45:25 +00:00
|
|
|
$this->io->write('<info>Updating '.($devMode ? 'dev ': '').'dependencies</info>');
|
2012-03-03 05:35:40 +00:00
|
|
|
|
|
|
|
$request->updateAll();
|
|
|
|
|
2012-04-14 13:45:25 +00:00
|
|
|
$links = $devMode ? $this->package->getDevRequires() : $this->package->getRequires();
|
2012-03-03 05:35:40 +00:00
|
|
|
|
|
|
|
foreach ($links as $link) {
|
|
|
|
$request->install($link->getTarget(), $link->getConstraint());
|
|
|
|
}
|
2012-04-15 17:05:50 +00:00
|
|
|
} elseif ($this->locker->isLocked($devMode)) {
|
2012-03-03 05:35:40 +00:00
|
|
|
$installFromLock = true;
|
2012-04-14 13:45:25 +00:00
|
|
|
$this->io->write('<info>Installing '.($devMode ? 'dev ': '').'dependencies from lock file</info>');
|
2012-03-03 05:35:40 +00:00
|
|
|
|
2012-04-14 13:45:25 +00:00
|
|
|
if (!$this->locker->isFresh() && !$devMode) {
|
2012-03-05 23:48:07 +00:00
|
|
|
$this->io->write('<warning>Your lock file is out of sync with your composer.json, run "composer.phar update" to update dependencies</warning>');
|
2012-03-03 05:35:40 +00:00
|
|
|
}
|
|
|
|
|
2012-04-14 13:45:25 +00:00
|
|
|
foreach ($this->locker->getLockedPackages($devMode) as $package) {
|
2012-03-03 05:35:40 +00:00
|
|
|
$version = $package->getVersion();
|
|
|
|
foreach ($aliases as $alias) {
|
|
|
|
if ($alias['package'] === $package->getName() && $alias['version'] === $package->getVersion()) {
|
|
|
|
$version = $alias['alias'];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$constraint = new VersionConstraint('=', $version);
|
|
|
|
$request->install($package->getName(), $constraint);
|
|
|
|
}
|
|
|
|
} else {
|
2012-04-14 13:45:25 +00:00
|
|
|
$this->io->write('<info>Installing '.($devMode ? 'dev ': '').'dependencies</info>');
|
2012-03-03 05:35:40 +00:00
|
|
|
|
2012-04-14 13:45:25 +00:00
|
|
|
$links = $devMode ? $this->package->getDevRequires() : $this->package->getRequires();
|
2012-03-03 05:35:40 +00:00
|
|
|
|
|
|
|
foreach ($links as $link) {
|
|
|
|
$request->install($link->getTarget(), $link->getConstraint());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-04-14 13:45:25 +00:00
|
|
|
// fix the version all installed packages that are not in the current local repo to prevent rogue updates
|
|
|
|
foreach ($installedRepo->getPackages() as $package) {
|
|
|
|
if ($package->getRepository() === $localRepo || $package->getRepository() instanceof PlatformRepository) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
$constraint = new VersionConstraint('=', $package->getVersion());
|
|
|
|
$request->install($package->getName(), $constraint);
|
|
|
|
}
|
|
|
|
|
2012-03-03 05:35:40 +00:00
|
|
|
// prepare solver
|
2012-03-10 00:16:37 +00:00
|
|
|
$policy = new DefaultPolicy();
|
|
|
|
$solver = new Solver($policy, $pool, $installedRepo);
|
2012-03-03 05:35:40 +00:00
|
|
|
|
|
|
|
// solve dependencies
|
2012-03-18 21:43:07 +00:00
|
|
|
try {
|
|
|
|
$operations = $solver->solve($request);
|
|
|
|
} catch (SolverProblemsException $e) {
|
|
|
|
$this->io->write('<error>Your requirements could not be solved to an installable set of packages.</error>');
|
|
|
|
$this->io->write($e->getMessage());
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
2012-03-03 05:35:40 +00:00
|
|
|
|
2012-04-02 19:46:05 +00:00
|
|
|
// force dev packages to be updated if we update or install from a (potentially new) lock
|
|
|
|
if ($this->update || $installFromLock) {
|
2012-03-03 05:35:40 +00:00
|
|
|
foreach ($localRepo->getPackages() as $package) {
|
|
|
|
// skip non-dev packages
|
|
|
|
if (!$package->isDev()) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
// skip packages that will be updated/uninstalled
|
|
|
|
foreach ($operations as $operation) {
|
2012-04-02 19:32:05 +00:00
|
|
|
if (('update' === $operation->getJobType() && $operation->getInitialPackage()->equals($package))
|
|
|
|
|| ('uninstall' === $operation->getJobType() && $operation->getPackage()->equals($package))
|
2012-03-03 05:35:40 +00:00
|
|
|
) {
|
|
|
|
continue 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-04-02 19:46:05 +00:00
|
|
|
// force update to latest on update
|
|
|
|
if ($this->update) {
|
|
|
|
$newPackage = $this->repositoryManager->findPackage($package->getName(), $package->getVersion());
|
|
|
|
if ($newPackage && $newPackage->getSourceReference() !== $package->getSourceReference()) {
|
|
|
|
$operations[] = new UpdateOperation($package, $newPackage);
|
|
|
|
}
|
|
|
|
} elseif ($installFromLock) {
|
|
|
|
// force update to locked version if it does not match the installed version
|
|
|
|
$lockData = $this->locker->getLockData();
|
|
|
|
unset($lockedReference);
|
|
|
|
foreach ($lockData['packages'] as $lockedPackage) {
|
|
|
|
if (!empty($lockedPackage['source-reference']) && strtolower($lockedPackage['package']) === $package->getName()) {
|
|
|
|
$lockedReference = $lockedPackage['source-reference'];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (isset($lockedReference) && $lockedReference !== $package->getSourceReference()) {
|
|
|
|
// changing the source ref to update to will be handled in the operations loop below
|
|
|
|
$operations[] = new UpdateOperation($package, $package);
|
|
|
|
}
|
2012-03-03 05:35:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// anti-alias local repository to allow updates to work fine
|
2012-04-14 13:45:25 +00:00
|
|
|
foreach ($localRepo->getPackages() as $package) {
|
2012-03-03 05:35:40 +00:00
|
|
|
if ($package instanceof AliasPackage) {
|
2012-04-14 13:45:25 +00:00
|
|
|
$package->getRepository()->addPackage(clone $package->getAliasOf());
|
|
|
|
$package->getRepository()->removePackage($package);
|
2012-03-03 05:35:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// execute operations
|
|
|
|
if (!$operations) {
|
2012-04-14 13:45:25 +00:00
|
|
|
$this->io->write('Nothing to install or update');
|
2012-03-03 05:35:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
foreach ($operations as $operation) {
|
2012-03-10 17:08:36 +00:00
|
|
|
if ($this->verbose) {
|
2012-03-05 23:48:07 +00:00
|
|
|
$this->io->write((string) $operation);
|
2012-03-03 05:35:40 +00:00
|
|
|
}
|
2012-04-14 10:07:49 +00:00
|
|
|
|
|
|
|
// collect suggestions
|
|
|
|
if ('install' === $operation->getJobType()) {
|
|
|
|
foreach ($operation->getPackage()->getSuggests() as $target => $reason) {
|
2012-04-15 15:44:47 +00:00
|
|
|
$this->suggestedPackages[] = array(
|
2012-04-14 10:07:49 +00:00
|
|
|
'source' => $operation->getPackage()->getPrettyName(),
|
|
|
|
'target' => $target,
|
|
|
|
'reason' => $reason,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-03-10 17:08:36 +00:00
|
|
|
if (!$this->dryRun) {
|
2012-03-05 23:48:07 +00:00
|
|
|
$this->eventDispatcher->dispatchPackageEvent(constant('Composer\Script\ScriptEvents::PRE_PACKAGE_'.strtoupper($operation->getJobType())), $operation);
|
2012-03-03 05:35:40 +00:00
|
|
|
|
|
|
|
// if installing from lock, restore dev packages' references to their locked state
|
|
|
|
if ($installFromLock) {
|
|
|
|
$package = null;
|
|
|
|
if ('update' === $operation->getJobType()) {
|
|
|
|
$package = $operation->getTargetPackage();
|
|
|
|
} elseif ('install' === $operation->getJobType()) {
|
|
|
|
$package = $operation->getPackage();
|
|
|
|
}
|
|
|
|
if ($package && $package->isDev()) {
|
2012-03-05 23:48:07 +00:00
|
|
|
$lockData = $this->locker->getLockData();
|
2012-03-03 05:35:40 +00:00
|
|
|
foreach ($lockData['packages'] as $lockedPackage) {
|
|
|
|
if (!empty($lockedPackage['source-reference']) && strtolower($lockedPackage['package']) === $package->getName()) {
|
|
|
|
$package->setSourceReference($lockedPackage['source-reference']);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-04-14 13:45:25 +00:00
|
|
|
$this->installationManager->execute($localRepo, $operation);
|
2012-03-03 05:35:40 +00:00
|
|
|
|
2012-03-05 23:48:07 +00:00
|
|
|
$this->eventDispatcher->dispatchPackageEvent(constant('Composer\Script\ScriptEvents::POST_PACKAGE_'.strtoupper($operation->getJobType())), $operation);
|
2012-03-12 11:24:11 +00:00
|
|
|
|
|
|
|
$localRepo->write();
|
2012-03-03 05:35:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-04-15 17:05:16 +00:00
|
|
|
// reload local repository for the dev pass to work ok with aliases since it was anti-aliased above
|
|
|
|
if (!$devMode) {
|
|
|
|
$localRepo->reload();
|
|
|
|
}
|
|
|
|
|
2012-04-15 15:44:47 +00:00
|
|
|
return true;
|
2012-04-14 13:45:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private function aliasPackages()
|
|
|
|
{
|
|
|
|
if (!$this->update && $this->locker->isLocked()) {
|
|
|
|
$aliases = $this->locker->getAliases();
|
|
|
|
} else {
|
|
|
|
$aliases = $this->package->getAliases();
|
2012-04-14 10:07:49 +00:00
|
|
|
}
|
|
|
|
|
2012-04-14 13:45:25 +00:00
|
|
|
foreach ($aliases as $alias) {
|
|
|
|
foreach ($this->repositoryManager->findPackages($alias['package'], $alias['version']) as $package) {
|
|
|
|
$package->setAlias($alias['alias_normalized']);
|
|
|
|
$package->setPrettyAlias($alias['alias']);
|
|
|
|
$package->getRepository()->addPackage(new AliasPackage($package, $alias['alias_normalized'], $alias['alias']));
|
|
|
|
}
|
|
|
|
foreach ($this->repositoryManager->getLocalRepositories() as $repo) {
|
|
|
|
foreach ($repo->findPackages($alias['package'], $alias['version']) as $package) {
|
|
|
|
$package->setAlias($alias['alias_normalized']);
|
|
|
|
$package->setPrettyAlias($alias['alias']);
|
|
|
|
$package->getRepository()->addPackage(new AliasPackage($package, $alias['alias_normalized'], $alias['alias']));
|
|
|
|
$package->getRepository()->removePackage($package);
|
2012-04-06 19:25:41 +00:00
|
|
|
}
|
2012-03-03 05:35:40 +00:00
|
|
|
}
|
|
|
|
}
|
2012-03-18 21:43:07 +00:00
|
|
|
|
2012-04-14 13:45:25 +00:00
|
|
|
return $aliases;
|
2012-03-03 05:35:40 +00:00
|
|
|
}
|
2012-03-05 23:48:07 +00:00
|
|
|
|
|
|
|
/**
|
2012-03-06 23:30:18 +00:00
|
|
|
* Create Installer
|
2012-03-10 00:16:37 +00:00
|
|
|
*
|
2012-03-05 23:48:07 +00:00
|
|
|
* @param IOInterface $io
|
|
|
|
* @param Composer $composer
|
|
|
|
* @param EventDispatcher $eventDispatcher
|
2012-03-06 23:30:18 +00:00
|
|
|
* @return Installer
|
2012-03-05 23:48:07 +00:00
|
|
|
*/
|
2012-03-10 00:16:37 +00:00
|
|
|
static public function create(IOInterface $io, Composer $composer, EventDispatcher $eventDispatcher = null)
|
2012-03-05 23:48:07 +00:00
|
|
|
{
|
2012-03-10 00:16:37 +00:00
|
|
|
$eventDispatcher = $eventDispatcher ?: new EventDispatcher($composer, $io);
|
|
|
|
|
2012-03-05 23:48:07 +00:00
|
|
|
return new static(
|
|
|
|
$io,
|
|
|
|
$composer->getPackage(),
|
|
|
|
$composer->getDownloadManager(),
|
|
|
|
$composer->getRepositoryManager(),
|
|
|
|
$composer->getLocker(),
|
|
|
|
$composer->getInstallationManager(),
|
|
|
|
$eventDispatcher
|
|
|
|
);
|
|
|
|
}
|
2012-03-10 17:08:36 +00:00
|
|
|
|
|
|
|
public function setAdditionalInstalledRepository(RepositoryInterface $additionalInstalledRepository)
|
|
|
|
{
|
|
|
|
$this->additionalInstalledRepository = $additionalInstalledRepository;
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* wether to run in drymode or not
|
|
|
|
*
|
|
|
|
* @param boolean $dryRun
|
|
|
|
* @return Installer
|
|
|
|
*/
|
2012-04-14 09:55:57 +00:00
|
|
|
public function setDryRun($dryRun = true)
|
2012-03-10 17:08:36 +00:00
|
|
|
{
|
2012-03-10 19:14:54 +00:00
|
|
|
$this->dryRun = (boolean) $dryRun;
|
2012-03-10 17:08:36 +00:00
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2012-04-14 09:55:57 +00:00
|
|
|
* prefer source installation
|
2012-03-10 17:08:36 +00:00
|
|
|
*
|
2012-04-14 09:55:57 +00:00
|
|
|
* @param boolean $preferSource
|
2012-03-10 17:08:36 +00:00
|
|
|
* @return Installer
|
|
|
|
*/
|
2012-04-14 09:55:57 +00:00
|
|
|
public function setPreferSource($preferSource = true)
|
2012-03-10 17:08:36 +00:00
|
|
|
{
|
2012-04-14 09:55:57 +00:00
|
|
|
$this->preferSource = (boolean) $preferSource;
|
2012-03-10 17:08:36 +00:00
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2012-04-14 09:55:57 +00:00
|
|
|
* update packages
|
2012-03-10 17:08:36 +00:00
|
|
|
*
|
2012-04-14 09:55:57 +00:00
|
|
|
* @param boolean $update
|
2012-03-10 17:08:36 +00:00
|
|
|
* @return Installer
|
|
|
|
*/
|
2012-04-14 09:55:57 +00:00
|
|
|
public function setUpdate($update = true)
|
2012-03-10 17:08:36 +00:00
|
|
|
{
|
2012-04-14 09:55:57 +00:00
|
|
|
$this->update = (boolean) $update;
|
2012-03-10 17:08:36 +00:00
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2012-04-14 09:55:57 +00:00
|
|
|
* enables dev packages
|
2012-03-10 17:08:36 +00:00
|
|
|
*
|
|
|
|
* @param boolean $update
|
|
|
|
* @return Installer
|
|
|
|
*/
|
2012-04-14 09:55:57 +00:00
|
|
|
public function setDevMode($devMode = true)
|
2012-03-10 17:08:36 +00:00
|
|
|
{
|
2012-04-14 09:55:57 +00:00
|
|
|
$this->devMode = (boolean) $devMode;
|
2012-03-10 17:08:36 +00:00
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* run in verbose mode
|
|
|
|
*
|
|
|
|
* @param boolean $verbose
|
|
|
|
* @return Installer
|
|
|
|
*/
|
2012-04-14 09:55:57 +00:00
|
|
|
public function setVerbose($verbose = true)
|
2012-03-10 17:08:36 +00:00
|
|
|
{
|
2012-03-10 19:14:54 +00:00
|
|
|
$this->verbose = (boolean) $verbose;
|
2012-03-10 17:08:36 +00:00
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
2012-03-03 05:35:40 +00:00
|
|
|
}
|