本文整理汇总了PHP中Composer\Repository\RepositoryManager::findPackages方法的典型用法代码示例。如果您正苦于以下问题:PHP RepositoryManager::findPackages方法的具体用法?PHP RepositoryManager::findPackages怎么用?PHP RepositoryManager::findPackages使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Composer\Repository\RepositoryManager
的用法示例。
在下文中一共展示了RepositoryManager::findPackages方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: aliasPackages
private function aliasPackages()
{
if (!$this->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->setAlias($alias['alias_normalized']);
$package->setPrettyAlias($alias['alias']);
$package->getRepository()->addPackage($aliasPackage = new AliasPackage($package, $alias['alias_normalized'], $alias['alias']));
$aliasPackage->setRootPackageAlias(true);
}
}
return $aliases;
}
示例2: 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()) {
//.........这里部分代码省略.........