本文整理汇总了PHP中Composer\Repository\RepositoryInterface::findPackage方法的典型用法代码示例。如果您正苦于以下问题:PHP RepositoryInterface::findPackage方法的具体用法?PHP RepositoryInterface::findPackage怎么用?PHP RepositoryInterface::findPackage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Composer\Repository\RepositoryInterface
的用法示例。
在下文中一共展示了RepositoryInterface::findPackage方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getPackage
/**
* @param string $name
* @param ConstraintInterface $constraint
* @return \Composer\Package\PackageInterface
*/
private function getPackage($name, ConstraintInterface $constraint)
{
$package = $this->repository->findPackage($name, $constraint);
if ($package === NULL) {
return new ComposerPackage($name, '0.0.0.1', '--no-dev');
}
return $package;
}
示例2: convertRepositoryToArray
/**
* Convert the information of all packages in a repository to an array used by json API.
*
* @param RepositoryInterface $repository The repository holding the packages to convert.
*
* @param bool $requiredOnly If true, return only the packages added to the root package as
* require.
*
* @param null|RepositoryInterface $upgradeList The packages available as upgrades.
*
* @return JsonArray
*/
public function convertRepositoryToArray(RepositoryInterface $repository, $requiredOnly = false, RepositoryInterface $upgradeList = null)
{
$requires = $requiredOnly ? $this->rootPackage->getRequires() : false;
$packages = new JsonArray();
/** @var \Composer\Package\PackageInterface $package */
foreach ($repository->getPackages() as $package) {
$name = $package->getPrettyName();
$esc = $packages->escape($name);
if (false === $requires || isset($requires[$name])) {
$upgradePkg = null;
if ($upgradeList) {
$upgradePkg = $upgradeList->findPackage($name, '*');
}
$packages->set($esc, $this->convertPackageToArray($package, $upgradePkg)->getData());
}
}
return $packages;
}
示例3: getPackage
/**
* finds a package by name and version if provided
*
* @param InputInterface $input
* @return PackageInterface
* @throws \InvalidArgumentException
*/
protected function getPackage(InputInterface $input, OutputInterface $output, RepositoryInterface $installedRepo, RepositoryInterface $repos)
{
// we have a name and a version so we can use ::findPackage
if ($input->getArgument('version')) {
return $repos->findPackage($input->getArgument('package'), $input->getArgument('version'));
}
// check if we have a local installation so we can grab the right package/version
foreach ($installedRepo->getPackages() as $package) {
if ($package->getName() === $input->getArgument('package')) {
return $package;
}
}
// we only have a name, so search for the highest version of the given package
$highestVersion = null;
foreach ($repos->findPackages($input->getArgument('package')) as $package) {
if (null === $highestVersion || version_compare($package->getVersion(), $highestVersion->getVersion(), '>=')) {
$highestVersion = $package;
}
}
return $highestVersion;
}
示例4: filterDevPackageOperations
/**
* @return OperationInterface[] filtered operations, dev packages are uninstalled and all operations on them ignored
*/
private function filterDevPackageOperations(array $devPackages, array $operations, RepositoryInterface $localRepo)
{
$finalOps = array();
$packagesToSkip = array();
foreach ($devPackages as $pkg) {
$packagesToSkip[$pkg->getName()] = true;
if ($installedDevPkg = $localRepo->findPackage($pkg->getName(), '*')) {
$finalOps[] = new UninstallOperation($installedDevPkg, 'non-dev install removing it');
}
}
// skip operations applied on dev packages
foreach ($operations as $op) {
$package = $op->getJobType() === 'update' ? $op->getTargetPackage() : $op->getPackage();
if (isset($packagesToSkip[$package->getName()])) {
continue;
}
$finalOps[] = $op;
}
return $finalOps;
}