本文整理汇总了PHP中Composer\Repository\RepositoryManager::getRepositories方法的典型用法代码示例。如果您正苦于以下问题:PHP RepositoryManager::getRepositories方法的具体用法?PHP RepositoryManager::getRepositories怎么用?PHP RepositoryManager::getRepositories使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Composer\Repository\RepositoryManager
的用法示例。
在下文中一共展示了RepositoryManager::getRepositories方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testWhatProvidesWithCamelcasePackageName
public function testWhatProvidesWithCamelcasePackageName()
{
$assetName = 'CamelCasePackage';
$name = $this->getType().'-asset/' . strtolower($assetName);
$rfs = $this->replaceRegistryRfsByMock();
$rfs->expects($this->at(0))
->method('getContents')
->will($this->throwException(new TransportException('Package not found', 404)));
$rfs->expects($this->at(1))
->method('getContents')
->will($this->throwException(new TransportException('Package not found', 404)));
$rfs->expects($this->at(2))
->method('getContents')
->will($this->throwException(new TransportException('Package not found', 404)));
$rfs->expects($this->at(3))
->method('getContents')
->will($this->returnValue(json_encode($this->getMockSearchResult($assetName))));
$rfs->expects($this->at(4))
->method('getContents')
->will($this->returnValue(json_encode($this->getMockPackageForVcsConfig())));
$this->assertCount(0, $this->rm->getRepositories());
$this->assertCount(0, $this->registry->whatProvides($this->pool, $name));
$this->assertCount(0, $this->registry->whatProvides($this->pool, $name));
$this->assertCount(1, $this->rm->getRepositories());
}
示例2: hasVcsRepository
/**
* Checks if the package vcs repository is already include in repository manager.
*
* @param string $name The package name of the vcs repository
*
* @return bool
*/
protected function hasVcsRepository($name)
{
foreach ($this->repositoryManager->getRepositories() as $mRepo) {
if ($mRepo instanceof AssetVcsRepository && $name === $mRepo->getComposerPackageName()) {
return true;
}
}
return false;
}
示例3: testPrepend
public function testPrepend()
{
$rm = new RepositoryManager($this->getMock('Composer\\IO\\IOInterface'), $this->getMock('Composer\\Config'), $this->getMockBuilder('Composer\\EventDispatcher\\EventDispatcher')->disableOriginalConstructor()->getMock());
$repository1 = $this->getMock('Composer\\Repository\\RepositoryInterface');
$repository2 = $this->getMock('Composer\\Repository\\RepositoryInterface');
$rm->addRepository($repository1);
$rm->prependRepository($repository2);
$this->assertEquals(array($repository2, $repository1), $rm->getRepositories());
}
示例4: doInstall
protected function doInstall($localRepo, $installedRepo, $aliases, $devMode = false)
{
$minimumStability = $this->package->getMinimumStability();
$stabilityFlags = $this->package->getStabilityFlags();
// init vars
$lockedRepository = null;
$repositories = null;
// initialize locker to create aliased packages
$installFromLock = false;
if (!$this->update && $this->locker->isLocked($devMode)) {
$installFromLock = true;
$lockedRepository = $this->locker->getLockedRepository($devMode);
$minimumStability = $this->locker->getMinimumStability();
$stabilityFlags = $this->locker->getStabilityFlags();
}
$this->whitelistUpdateDependencies($localRepo, $devMode, $this->package->getRequires(), $this->package->getDevRequires());
$this->io->write('<info>Loading composer repositories with package information</info>');
// creating repository pool
$policy = new DefaultPolicy();
$pool = new Pool($minimumStability, $stabilityFlags);
$pool->addRepository($installedRepo, $aliases);
if ($installFromLock) {
$pool->addRepository($lockedRepository, $aliases);
}
if (!$installFromLock || !$this->locker->isCompleteFormat($devMode)) {
$repositories = $this->repositoryManager->getRepositories();
foreach ($repositories as $repository) {
$pool->addRepository($repository, $aliases);
}
}
// creating requirements request
$request = new Request($pool);
$constraint = new VersionConstraint('=', $this->package->getVersion());
$constraint->setPrettyString($this->package->getPrettyVersion());
$request->install($this->package->getName(), $constraint);
if ($this->update) {
$this->io->write('<info>Updating ' . ($devMode ? 'dev ' : '') . 'dependencies</info>');
$request->updateAll();
$links = $devMode ? $this->package->getDevRequires() : $this->package->getRequires();
foreach ($links as $link) {
$request->install($link->getTarget(), $link->getConstraint());
}
} elseif ($installFromLock) {
$this->io->write('<info>Installing ' . ($devMode ? 'dev ' : '') . 'dependencies from lock file</info>');
if (!$this->locker->isCompleteFormat($devMode)) {
$this->io->write('<warning>Warning: Your lock file is in a deprecated format. It will most likely take a *long* time for composer to install dependencies, and may cause dependency solving issues.</warning>');
}
if (!$this->locker->isFresh() && !$devMode) {
$this->io->write('<warning>Warning: The lock file is not up to date with the latest changes in composer.json, you may be getting outdated dependencies, run update to update them.</warning>');
}
foreach ($lockedRepository->getPackages() as $package) {
$version = $package->getVersion();
if (isset($aliases[$package->getName()][$version])) {
$version = $aliases[$package->getName()][$version]['alias_normalized'];
}
$constraint = new VersionConstraint('=', $version);
$constraint->setPrettyString($package->getPrettyVersion());
$request->install($package->getName(), $constraint);
}
} else {
$this->io->write('<info>Installing ' . ($devMode ? 'dev ' : '') . 'dependencies</info>');
$links = $devMode ? $this->package->getDevRequires() : $this->package->getRequires();
foreach ($links as $link) {
$request->install($link->getTarget(), $link->getConstraint());
}
}
// fix the version of all installed packages (+ platform) that are not
// in the current local repo to prevent rogue updates (e.g. non-dev
// updating when in dev)
foreach ($installedRepo->getPackages() as $package) {
if ($package->getRepository() === $localRepo) {
continue;
}
$constraint = new VersionConstraint('=', $package->getVersion());
$constraint->setPrettyString($package->getPrettyVersion());
$request->install($package->getName(), $constraint);
}
// if the updateWhitelist is enabled, packages not in it are also fixed
// to the version specified in the lock, or their currently installed version
if ($this->update && $this->updateWhitelist) {
if ($this->locker->isLocked($devMode)) {
$currentPackages = $this->locker->getLockedRepository($devMode)->getPackages();
} else {
$currentPackages = $installedRepo->getPackages();
}
// collect links from composer as well as installed packages
$candidates = array();
foreach ($links as $link) {
$candidates[$link->getTarget()] = true;
}
foreach ($localRepo->getPackages() as $package) {
$candidates[$package->getName()] = true;
}
// fix them to the version in lock (or currently installed) if they are not updateable
foreach ($candidates as $candidate => $dummy) {
foreach ($currentPackages as $curPackage) {
if ($curPackage->getName() === $candidate) {
if ($this->isUpdateable($curPackage)) {
break;
}
//.........这里部分代码省略.........
示例5: doInstall
protected function doInstall($localRepo, $installedRepo, $platformRepo, $aliases, $withDevReqs)
{
// init vars
$lockedRepository = null;
$repositories = null;
// initialize locker to create aliased packages
$installFromLock = false;
if (!$this->update && $this->locker->isLocked()) {
$installFromLock = true;
try {
$lockedRepository = $this->locker->getLockedRepository($withDevReqs);
} catch (\RuntimeException $e) {
// if there are dev requires, then we really can not install
if ($this->package->getDevRequires()) {
throw $e;
}
// no require-dev in composer.json and the lock file was created with no dev info, so skip them
$lockedRepository = $this->locker->getLockedRepository();
}
}
$this->whitelistUpdateDependencies($localRepo, $withDevReqs, $this->package->getRequires(), $this->package->getDevRequires());
$this->io->writeError('<info>Loading composer repositories with package information</info>');
// creating repository pool
$policy = $this->createPolicy();
$pool = $this->createPool($withDevReqs, $lockedRepository);
$pool->addRepository($installedRepo, $aliases);
if ($installFromLock) {
$pool->addRepository($lockedRepository, $aliases);
}
if (!$installFromLock) {
$repositories = $this->repositoryManager->getRepositories();
foreach ($repositories as $repository) {
$pool->addRepository($repository, $aliases);
}
}
// creating requirements request
$request = $this->createRequest($pool, $this->package, $platformRepo);
if (!$installFromLock) {
// remove unstable packages from the localRepo if they don't match the current stability settings
$removedUnstablePackages = array();
foreach ($localRepo->getPackages() as $package) {
if (!$pool->isPackageAcceptable($package->getNames(), $package->getStability()) && $this->installationManager->isPackageInstalled($localRepo, $package)) {
$removedUnstablePackages[$package->getName()] = true;
$request->remove($package->getName(), new VersionConstraint('=', $package->getVersion()));
}
}
}
if ($this->update) {
$this->io->writeError('<info>Updating dependencies' . ($withDevReqs ? ' (including require-dev)' : '') . '</info>');
$request->updateAll();
if ($withDevReqs) {
$links = array_merge($this->package->getRequires(), $this->package->getDevRequires());
} else {
$links = $this->package->getRequires();
}
foreach ($links as $link) {
$request->install($link->getTarget(), $link->getConstraint());
}
// if the updateWhitelist is enabled, packages not in it are also fixed
// to the version specified in the lock, or their currently installed version
if ($this->updateWhitelist) {
if ($this->locker->isLocked()) {
try {
$currentPackages = $this->locker->getLockedRepository($withDevReqs)->getPackages();
} catch (\RuntimeException $e) {
// fetch only non-dev packages from lock if doing a dev update fails due to a previously incomplete lock file
$currentPackages = $this->locker->getLockedRepository()->getPackages();
}
} else {
$currentPackages = $installedRepo->getPackages();
}
// collect packages to fixate from root requirements as well as installed packages
$candidates = array();
foreach ($links as $link) {
$candidates[$link->getTarget()] = true;
}
foreach ($localRepo->getPackages() as $package) {
$candidates[$package->getName()] = true;
}
// fix them to the version in lock (or currently installed) if they are not updateable
foreach ($candidates as $candidate => $dummy) {
foreach ($currentPackages as $curPackage) {
if ($curPackage->getName() === $candidate) {
if (!$this->isUpdateable($curPackage) && !isset($removedUnstablePackages[$curPackage->getName()])) {
$constraint = new VersionConstraint('=', $curPackage->getVersion());
$request->install($curPackage->getName(), $constraint);
}
break;
}
}
}
}
} elseif ($installFromLock) {
$this->io->writeError('<info>Installing dependencies' . ($withDevReqs ? ' (including require-dev)' : '') . ' from lock file</info>');
if (!$this->locker->isFresh()) {
$this->io->writeError('<warning>Warning: The lock file is not up to date with the latest changes in composer.json. You may be getting outdated dependencies. Run update to update them.</warning>');
}
foreach ($lockedRepository->getPackages() as $package) {
$version = $package->getVersion();
if (isset($aliases[$package->getName()][$version])) {
//.........这里部分代码省略.........
示例6: doInstall
protected function doInstall($localRepo, $installedRepo, $aliases, $devMode = false)
{
$minimumStability = $this->package->getMinimumStability();
$stabilityFlags = $this->package->getStabilityFlags();
// initialize locker to create aliased packages
if (!$this->update && $this->locker->isLocked($devMode)) {
$lockedPackages = $this->locker->getLockedPackages($devMode);
$minimumStability = $this->locker->getMinimumStability();
$stabilityFlags = $this->locker->getStabilityFlags();
}
$this->whitelistUpdateDependencies($localRepo, $devMode, $this->package->getRequires(), $this->package->getDevRequires());
$this->io->write('<info>Loading composer repositories with package information</info>');
// creating repository pool
$pool = new Pool($minimumStability, $stabilityFlags);
$pool->addRepository($installedRepo);
foreach ($this->repositoryManager->getRepositories() as $repository) {
$pool->addRepository($repository);
}
// creating requirements request
$installFromLock = false;
$request = new Request($pool);
$constraint = new VersionConstraint('=', $this->package->getVersion());
$request->install($this->package->getName(), $constraint);
if ($this->update) {
$this->io->write('<info>Updating ' . ($devMode ? 'dev ' : '') . 'dependencies</info>');
$request->updateAll();
$links = $devMode ? $this->package->getDevRequires() : $this->package->getRequires();
foreach ($links as $link) {
$request->install($link->getTarget(), $link->getConstraint());
}
} elseif ($this->locker->isLocked($devMode)) {
$installFromLock = true;
$this->io->write('<info>Installing ' . ($devMode ? 'dev ' : '') . 'dependencies from lock file</info>');
if (!$this->locker->isFresh() && !$devMode) {
$this->io->write('<warning>Your lock file is out of sync with your composer.json, run "composer.phar update" to update dependencies</warning>');
}
foreach ($lockedPackages as $package) {
$version = $package->getVersion();
foreach ($aliases as $alias) {
if ($alias['package'] === $package->getName() && $alias['version'] === $package->getVersion()) {
$version = $alias['alias_normalized'];
break;
}
}
$constraint = new VersionConstraint('=', $version);
$request->install($package->getName(), $constraint);
}
} else {
$this->io->write('<info>Installing ' . ($devMode ? 'dev ' : '') . 'dependencies</info>');
$links = $devMode ? $this->package->getDevRequires() : $this->package->getRequires();
foreach ($links as $link) {
$request->install($link->getTarget(), $link->getConstraint());
}
}
// fix the version of all installed packages (+ platform) that are not
// in the current local repo to prevent rogue updates (e.g. non-dev
// updating when in dev)
foreach ($installedRepo->getPackages() as $package) {
if ($package->getRepository() === $localRepo) {
continue;
}
$constraint = new VersionConstraint('=', $package->getVersion());
$request->install($package->getName(), $constraint);
}
// if the updateWhitelist is enabled, packages not in it are also fixed
// to the version specified in the lock, or their currently installed version
if ($this->update && $this->updateWhitelist) {
if ($this->locker->isLocked($devMode)) {
$currentPackages = $this->locker->getLockedPackages($devMode);
} else {
$currentPackages = $installedRepo->getPackages();
}
// collect links from composer as well as installed packages
$candidates = array();
foreach ($links as $link) {
$candidates[$link->getTarget()] = true;
}
foreach ($localRepo->getPackages() as $package) {
$candidates[$package->getName()] = true;
}
// fix them to the version in lock (or currently installed) if they are not updateable
foreach ($candidates as $candidate => $dummy) {
foreach ($currentPackages as $curPackage) {
if ($curPackage->getName() === $candidate) {
if ($this->isUpdateable($curPackage)) {
break;
}
$constraint = new VersionConstraint('=', $curPackage->getVersion());
$request->install($curPackage->getName(), $constraint);
}
}
}
}
// prepare solver
$policy = new DefaultPolicy();
$solver = new Solver($policy, $pool, $installedRepo);
// solve dependencies
try {
$operations = $solver->solve($request);
} catch (SolverProblemsException $e) {
//.........这里部分代码省略.........
示例7: doInstall
/**
* @param RepositoryInterface $localRepo
* @param RepositoryInterface $installedRepo
* @param PlatformRepository $platformRepo
* @param array $aliases
* @return array [int, PackageInterfaces[]|null] with the exit code and an array of dev packages on update, or null on install
*/
protected function doInstall($localRepo, $installedRepo, $platformRepo, $aliases)
{
// init vars
$lockedRepository = null;
$repositories = null;
// initialize locked repo if we are installing from lock or in a partial update
// and a lock file is present as we need to force install non-whitelisted lock file
// packages in that case
if (!$this->update || !empty($this->updateWhitelist) && $this->locker->isLocked()) {
try {
$lockedRepository = $this->locker->getLockedRepository($this->devMode);
} catch (\RuntimeException $e) {
// if there are dev requires, then we really can not install
if ($this->package->getDevRequires()) {
throw $e;
}
// no require-dev in composer.json and the lock file was created with no dev info, so skip them
$lockedRepository = $this->locker->getLockedRepository();
}
}
$this->whitelistUpdateDependencies($localRepo, $this->package->getRequires(), $this->package->getDevRequires());
$this->io->writeError('<info>Loading composer repositories with package information</info>');
// creating repository pool
$policy = $this->createPolicy();
$pool = $this->createPool($this->update ? null : $lockedRepository);
$pool->addRepository($installedRepo, $aliases);
if ($this->update) {
$repositories = $this->repositoryManager->getRepositories();
foreach ($repositories as $repository) {
$pool->addRepository($repository, $aliases);
}
}
// Add the locked repository after the others in case we are doing a
// partial update so missing packages can be found there still.
// For installs from lock it's the only one added so it is first
if ($lockedRepository) {
$pool->addRepository($lockedRepository, $aliases);
}
// creating requirements request
$request = $this->createRequest($this->package, $platformRepo);
if ($this->update) {
// remove unstable packages from the localRepo if they don't match the current stability settings
$removedUnstablePackages = array();
foreach ($localRepo->getPackages() as $package) {
if (!$pool->isPackageAcceptable($package->getNames(), $package->getStability()) && $this->installationManager->isPackageInstalled($localRepo, $package)) {
$removedUnstablePackages[$package->getName()] = true;
$request->remove($package->getName(), new Constraint('=', $package->getVersion()));
}
}
$this->io->writeError('<info>Updating dependencies' . ($this->devMode ? ' (including require-dev)' : '') . '</info>');
$request->updateAll();
$links = array_merge($this->package->getRequires(), $this->package->getDevRequires());
foreach ($links as $link) {
$request->install($link->getTarget(), $link->getConstraint());
}
// if the updateWhitelist is enabled, packages not in it are also fixed
// to the version specified in the lock, or their currently installed version
if ($this->updateWhitelist) {
$currentPackages = $this->getCurrentPackages($installedRepo);
// collect packages to fixate from root requirements as well as installed packages
$candidates = array();
foreach ($links as $link) {
$candidates[$link->getTarget()] = true;
$rootRequires[$link->getTarget()] = $link;
}
foreach ($currentPackages as $package) {
$candidates[$package->getName()] = true;
}
// fix them to the version in lock (or currently installed) if they are not updateable
foreach ($candidates as $candidate => $dummy) {
foreach ($currentPackages as $curPackage) {
if ($curPackage->getName() === $candidate) {
if (!$this->isUpdateable($curPackage) && !isset($removedUnstablePackages[$curPackage->getName()])) {
$constraint = new Constraint('=', $curPackage->getVersion());
$description = $this->locker->isLocked() ? '(locked at' : '(installed at';
$requiredAt = isset($rootRequires[$candidate]) ? ', required as ' . $rootRequires[$candidate]->getPrettyConstraint() : '';
$constraint->setPrettyString($description . ' ' . $curPackage->getPrettyVersion() . $requiredAt . ')');
$request->install($curPackage->getName(), $constraint);
}
break;
}
}
}
}
} else {
$this->io->writeError('<info>Installing dependencies' . ($this->devMode ? ' (including require-dev)' : '') . ' from lock file</info>');
if (!$this->locker->isFresh()) {
$this->io->writeError('<warning>Warning: The lock file is not up to date with the latest changes in composer.json. You may be getting outdated dependencies. Run update to update them.</warning>', true, IOInterface::QUIET);
}
foreach ($lockedRepository->getPackages() as $package) {
$version = $package->getVersion();
if (isset($aliases[$package->getName()][$version])) {
$version = $aliases[$package->getName()][$version]['alias_normalized'];
//.........这里部分代码省略.........
示例8: doInstall
protected function doInstall($localRepo, $installedRepo, $aliases, $devMode = false)
{
// creating repository pool
$pool = new Pool();
$pool->addRepository($installedRepo);
foreach ($this->repositoryManager->getRepositories() as $repository) {
$pool->addRepository($repository);
}
// creating requirements request
$installFromLock = false;
$request = new Request($pool);
if ($this->update) {
$this->io->write('<info>Updating ' . ($devMode ? 'dev ' : '') . 'dependencies</info>');
$request->updateAll();
$links = $devMode ? $this->package->getDevRequires() : $this->package->getRequires();
foreach ($links as $link) {
$request->install($link->getTarget(), $link->getConstraint());
}
} elseif ($this->locker->isLocked($devMode)) {
$installFromLock = true;
$this->io->write('<info>Installing ' . ($devMode ? 'dev ' : '') . 'dependencies from lock file</info>');
if (!$this->locker->isFresh() && !$devMode) {
$this->io->write('<warning>Your lock file is out of sync with your composer.json, run "composer.phar update" to update dependencies</warning>');
}
foreach ($this->locker->getLockedPackages($devMode) as $package) {
$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 {
$this->io->write('<info>Installing ' . ($devMode ? 'dev ' : '') . 'dependencies</info>');
$links = $devMode ? $this->package->getDevRequires() : $this->package->getRequires();
foreach ($links as $link) {
$request->install($link->getTarget(), $link->getConstraint());
}
}
// 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);
}
// prepare solver
$policy = new DefaultPolicy();
$solver = new Solver($policy, $pool, $installedRepo);
// solve dependencies
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;
}
// force dev packages to be updated if we update or install from a (potentially new) lock
if ($this->update || $installFromLock) {
foreach ($localRepo->getPackages() as $package) {
// skip non-dev packages
if (!$package->isDev()) {
continue;
}
// skip packages that will be updated/uninstalled
foreach ($operations as $operation) {
if ('update' === $operation->getJobType() && $operation->getInitialPackage()->equals($package) || 'uninstall' === $operation->getJobType() && $operation->getPackage()->equals($package)) {
continue 2;
}
}
// 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);
}
}
}
}
// anti-alias local repository to allow updates to work fine
foreach ($localRepo->getPackages() as $package) {
if ($package instanceof AliasPackage) {
//.........这里部分代码省略.........
示例9: run
/**
* Run installation (or update)
*
* @param Boolean $preferSource
* @param Boolean $dryRun
* @param Boolean $verbose
* @param Boolean $noInstallRecommends
* @param Boolean $installSuggests
* @param Boolean $update
* @param RepositoryInterface $additionalInstalledRepository
*/
public function run($preferSource = false, $dryRun = false, $verbose = false, $noInstallRecommends = false, $installSuggests = false, $update = false, RepositoryInterface $additionalInstalledRepository = null)
{
if ($dryRun) {
$verbose = true;
}
if ($preferSource) {
$this->downloadManager->setPreferSource(true);
}
$this->repositoryManager = $this->repositoryManager;
// create local repo, this contains all packages that are installed in the local project
$localRepo = $this->repositoryManager->getLocalRepository();
// create installed repo, this contains all local packages + platform packages (php & extensions)
$installedRepo = new CompositeRepository(array($localRepo, new PlatformRepository()));
if ($additionalInstalledRepository) {
$installedRepo->addRepository($additionalInstalledRepository);
}
// prepare aliased packages
if (!$update && $this->locker->isLocked()) {
$aliases = $this->locker->getAliases();
} else {
$aliases = $this->package->getAliases();
}
foreach ($aliases as $alias) {
foreach ($this->repositoryManager->findPackages($alias['package'], $alias['version']) as $package) {
$package->getRepository()->addPackage(new AliasPackage($package, $alias['alias_normalized'], $alias['alias']));
}
foreach ($this->repositoryManager->getLocalRepository()->findPackages($alias['package'], $alias['version']) as $package) {
$this->repositoryManager->getLocalRepository()->addPackage(new AliasPackage($package, $alias['alias_normalized'], $alias['alias']));
$this->repositoryManager->getLocalRepository()->removePackage($package);
}
}
// creating repository pool
$pool = new Pool();
$pool->addRepository($installedRepo);
foreach ($this->repositoryManager->getRepositories() as $repository) {
$pool->addRepository($repository);
}
// dispatch pre event
if (!$dryRun) {
$eventName = $update ? ScriptEvents::PRE_UPDATE_CMD : ScriptEvents::PRE_INSTALL_CMD;
$this->eventDispatcher->dispatchCommandEvent($eventName);
}
// creating requirements request
$installFromLock = false;
$request = new Request($pool);
if ($update) {
$this->io->write('<info>Updating dependencies</info>');
$request->updateAll();
$links = $this->collectLinks($noInstallRecommends, $installSuggests);
foreach ($links as $link) {
$request->install($link->getTarget(), $link->getConstraint());
}
} elseif ($this->locker->isLocked()) {
$installFromLock = true;
$this->io->write('<info>Installing from lock file</info>');
if (!$this->locker->isFresh()) {
$this->io->write('<warning>Your lock file is out of sync with your composer.json, run "composer.phar update" to update dependencies</warning>');
}
foreach ($this->locker->getLockedPackages() as $package) {
$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 {
$this->io->write('<info>Installing dependencies</info>');
$links = $this->collectLinks($noInstallRecommends, $installSuggests);
foreach ($links as $link) {
$request->install($link->getTarget(), $link->getConstraint());
}
}
// prepare solver
$policy = new DefaultPolicy();
$solver = new Solver($policy, $pool, $installedRepo);
// solve dependencies
$operations = $solver->solve($request);
// force dev packages to be updated to latest reference on update
if ($update) {
foreach ($localRepo->getPackages() as $package) {
if ($package instanceof AliasPackage) {
$package = $package->getAliasOf();
}
// skip non-dev packages
if (!$package->isDev()) {
//.........这里部分代码省略.........