当前位置: 首页>>代码示例>>PHP>>正文


PHP RepositoryInterface::findPackage方法代码示例

本文整理汇总了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;
 }
开发者ID:vojtasvoboda,项目名称:victor,代码行数:13,代码来源:DependencyResolver.php

示例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;
 }
开发者ID:tenside,项目名称:core,代码行数:30,代码来源:PackageConverter.php

示例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;
 }
开发者ID:nicodmf,项目名称:composer,代码行数:28,代码来源:ShowCommand.php

示例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;
 }
开发者ID:Rudloff,项目名称:composer,代码行数:23,代码来源:Installer.php


注:本文中的Composer\Repository\RepositoryInterface::findPackage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。