當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。