當前位置: 首頁>>代碼示例>>PHP>>正文


PHP RepositoryInterface::hasPackage方法代碼示例

本文整理匯總了PHP中Composer\Repository\RepositoryInterface::hasPackage方法的典型用法代碼示例。如果您正苦於以下問題:PHP RepositoryInterface::hasPackage方法的具體用法?PHP RepositoryInterface::hasPackage怎麽用?PHP RepositoryInterface::hasPackage使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Composer\Repository\RepositoryInterface的用法示例。


在下文中一共展示了RepositoryInterface::hasPackage方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: markAliasInstalled

    public function markAliasInstalled(RepositoryInterface $repo, MarkAliasInstalledOperation $operation)
    {
        $package = $operation->getPackage();

        $this->installed[] = $package;
        $this->trace[] = (string) $operation;

        if (!$repo->hasPackage($package)) {
            $repo->addPackage($package);
        }
    }
開發者ID:robywan,項目名稱:composer,代碼行數:11,代碼來源:InstallationManagerMock.php

示例2: markAliasInstalled

 /**
  * Executes markAliasInstalled operation.
  *
  * @param RepositoryInterface         $repo      repository in which to check
  * @param MarkAliasInstalledOperation $operation operation instance
  */
 public function markAliasInstalled(RepositoryInterface $repo, MarkAliasInstalledOperation $operation)
 {
     $package = $operation->getPackage();
     if (!$repo->hasPackage($package)) {
         $repo->addPackage(clone $package);
     }
 }
開發者ID:nickelc,項目名稱:composer,代碼行數:13,代碼來源:InstallationManager.php

示例3: printVersions

 /**
  * prints all available versions of this package and highlights the installed one if any
  */
 protected function printVersions(InputInterface $input, OutputInterface $output, PackageInterface $package, RepositoryInterface $installedRepo, RepositoryInterface $repos)
 {
     if ($input->getArgument('version')) {
         $output->writeln('<info>version</info>  : ' . $package->getPrettyVersion());
         return;
     }
     $versions = array();
     foreach ($repos->findPackages($package->getName()) as $version) {
         $versions[$version->getPrettyVersion()] = $version->getVersion();
     }
     uasort($versions, 'version_compare');
     $versions = implode(', ', array_keys(array_reverse($versions)));
     // highlight installed version
     if ($installedRepo->hasPackage($package)) {
         $versions = str_replace($package->getPrettyVersion(), '<info>* ' . $package->getPrettyVersion() . '</info>', $versions);
     }
     $output->writeln('<info>versions</info> : ' . $versions);
 }
開發者ID:nicodmf,項目名稱:composer,代碼行數:21,代碼來源:ShowCommand.php

示例4: getPackage

 protected function getPackage(RepositoryInterface $installedRepo, RepositoryInterface $repos, $name, $version = null)
 {
     $name = strtolower($name);
     $constraint = null;
     if ($version) {
         $constraint = $this->versionParser->parseConstraints($version);
     }
     $policy = new DefaultPolicy();
     $pool = new Pool('dev');
     $pool->addRepository($repos);
     $matchedPackage = null;
     $versions = array();
     $matches = $pool->whatProvides($name, $constraint);
     foreach ($matches as $index => $package) {
         // skip providers/replacers
         if ($package->getName() !== $name) {
             unset($matches[$index]);
             continue;
         }
         // select an exact match if it is in the installed repo and no specific version was required
         if (null === $version && $installedRepo->hasPackage($package)) {
             $matchedPackage = $package;
         }
         $versions[$package->getPrettyVersion()] = $package->getVersion();
         $matches[$index] = $package->getId();
     }
     // select prefered package according to policy rules
     if (!$matchedPackage && $matches && ($prefered = $policy->selectPreferedPackages($pool, array(), $matches))) {
         $matchedPackage = $pool->literalToPackage($prefered[0]);
     }
     return array($matchedPackage, $versions);
 }
開發者ID:jarves,項目名稱:jarves,代碼行數:32,代碼來源:ManagerController.php

示例5: printVersions

 /**
  * prints all available versions of this package and highlights the installed one if any
  */
 protected function printVersions(InputInterface $input, OutputInterface $output, CompletePackageInterface $package, array $versions, RepositoryInterface $installedRepo, RepositoryInterface $repos)
 {
     uasort($versions, 'version_compare');
     $versions = array_keys(array_reverse($versions));
     // highlight installed version
     if ($installedRepo->hasPackage($package)) {
         $installedVersion = $package->getPrettyVersion();
         $key = array_search($installedVersion, $versions);
         if (false !== $key) {
             $versions[$key] = '<info>* ' . $installedVersion . '</info>';
         }
     }
     $versions = implode(', ', $versions);
     $output->writeln('<info>versions</info> : ' . $versions);
 }
開發者ID:aminembarki,項目名稱:composer,代碼行數:18,代碼來源:ShowCommand.php

示例6: getPackage

 /**
  * Finds a package by name and version if provided.
  *
  * @param RepositoryInterface $installedRepo
  * @param RepositoryInterface $repos
  * @param string              $name
  * @param string|null         $version
  *
  * @throws \InvalidArgumentException
  *
  * @return array [CompletePackageInterface, array of versions]
  */
 protected function getPackage(RepositoryInterface $installedRepo, RepositoryInterface $repos, $name, $version = null)
 {
     $name = strtolower($name);
     $constraint = null;
     if ($version !== null) {
         $constraint = $this->versionParser->parseConstraints($version);
     }
     $policy = new DefaultPolicy();
     $pool = new Pool('dev');
     $pool->addRepository($repos);
     $matchedPackage = null;
     $versions = [];
     $matches = $pool->whatProvides($name, $constraint);
     foreach ($matches as $index => $package) {
         // Skip providers/replacers.
         if ($package->getName() !== $name) {
             unset($matches[$index]);
             continue;
         }
         // Select an exact match if it is in the installed repo and no specific version was required.
         if ($version === null && $installedRepo->hasPackage($package)) {
             $matchedPackage = $package;
         }
         $versions[$package->getPrettyVersion()] = $package->getVersion();
         $matches[$index] = $package->getId();
     }
     // Select prefered package according to policy rules.
     if (!$matchedPackage && !empty($matches) && ($prefered = $policy->selectPreferredPackages($pool, [], $matches))) {
         $matchedPackage = $pool->literalToPackage($prefered[0]);
     }
     // If we have package result, return them.
     if ($matchedPackage) {
         return [$matchedPackage->getName() => ['package' => $matchedPackage, 'versions' => $versions]];
     }
     return null;
 }
開發者ID:nectd,項目名稱:nectd-web,代碼行數:48,代碼來源:ShowPackage.php


注:本文中的Composer\Repository\RepositoryInterface::hasPackage方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。