当前位置: 首页>>代码示例>>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;未经允许,请勿转载。