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


PHP Repository\RepositoryInterface类代码示例

本文整理汇总了PHP中Composer\Repository\RepositoryInterface的典型用法代码示例。如果您正苦于以下问题:PHP RepositoryInterface类的具体用法?PHP RepositoryInterface怎么用?PHP RepositoryInterface使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了RepositoryInterface类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: loadRepository

 public function loadRepository(RepositoryInterface $repo)
 {
     foreach ($repo->getPackages() as $package) {
         if ($package instanceof AliasPackage) {
             continue;
         }
         if ('composer-plugin' === $package->getType()) {
             $requiresComposer = null;
             foreach ($package->getRequires() as $link) {
                 if ($link->getTarget() == 'composer-plugin-api') {
                     $requiresComposer = $link->getConstraint();
                 }
             }
             if (!$requiresComposer) {
                 throw new \RuntimeException("Plugin " . $package->getName() . " is missing a require statement for a version of the composer-plugin-api package.");
             }
             if (!$requiresComposer->matches(new VersionConstraint('==', $this->versionParser->normalize(PluginInterface::PLUGIN_API_VERSION)))) {
                 $this->io->writeError("<warning>The plugin " . $package->getName() . " requires a version of composer-plugin-api that does not match your composer installation. You may need to run composer update with the '--no-plugins' option.</warning>");
             }
             $this->registerPackage($package);
         }
         if ('composer-installer' === $package->getType()) {
             $this->registerPackage($package);
         }
     }
 }
开发者ID:VicDeo,项目名称:poc,代码行数:26,代码来源:PluginManager.php

示例2: update

 /**
  * Update a project
  *
  * @param \Packagist\WebBundle\Entity\Package $package
  * @param RepositoryInterface $repository the repository instance used to update from
  * @param int $flags a few of the constants of this class
  * @param \DateTime $start
  */
 public function update(Package $package, RepositoryInterface $repository, $flags = 0, \DateTime $start = null)
 {
     $blacklist = '{^symfony/symfony (2.0.[456]|dev-charset|dev-console)}i';
     if (null === $start) {
         $start = new \DateTime();
     }
     $pruneDate = clone $start;
     $pruneDate->modify('-8days');
     $versions = $repository->getPackages();
     $em = $this->doctrine->getManager();
     if ($repository->hadInvalidBranches()) {
         throw new InvalidRepositoryException('Some branches contained invalid data and were discarded, it is advised to review the log and fix any issues present in branches');
     }
     usort($versions, function ($a, $b) {
         $aVersion = $a->getVersion();
         $bVersion = $b->getVersion();
         if ($aVersion === '9999999-dev' || 'dev-' === substr($aVersion, 0, 4)) {
             $aVersion = 'dev';
         }
         if ($bVersion === '9999999-dev' || 'dev-' === substr($bVersion, 0, 4)) {
             $bVersion = 'dev';
         }
         if ($aVersion === $bVersion) {
             return $a->getReleaseDate() > $b->getReleaseDate() ? 1 : -1;
         }
         return version_compare($a->getVersion(), $b->getVersion());
     });
     $versionRepository = $this->doctrine->getRepository('PackagistWebBundle:Version');
     if ($flags & self::DELETE_BEFORE) {
         foreach ($package->getVersions() as $version) {
             $versionRepository->remove($version);
         }
         $em->flush();
         $em->refresh($package);
     }
     foreach ($versions as $version) {
         if ($version instanceof AliasPackage) {
             continue;
         }
         if (preg_match($blacklist, $version->getName() . ' ' . $version->getPrettyVersion())) {
             continue;
         }
         $this->updateInformation($package, $version, $flags);
         $em->flush();
     }
     // remove outdated versions
     foreach ($package->getVersions() as $version) {
         if ($version->getUpdatedAt() < $pruneDate) {
             $versionRepository->remove($version);
         }
     }
     $package->setUpdatedAt(new \DateTime());
     $package->setCrawledAt(new \DateTime());
     $em->flush();
 }
开发者ID:rdohms,项目名称:packagist,代码行数:63,代码来源:Updater.php

示例3: addRepository

 /**
  * Adds a repository and its packages to this package pool
  *
  * @param RepositoryInterface $repo A package repository
  */
 public function addRepository(RepositoryInterface $repo)
 {
     $this->repositories[] = $repo;
     foreach ($repo->getPackages() as $package) {
         $package->setId(count($this->packages) + 1);
         $this->packages[] = $package;
         foreach ($package->getNames() as $name) {
             $this->packageByName[$name][] = $package;
         }
     }
 }
开发者ID:nlegoff,项目名称:composer,代码行数:16,代码来源:Pool.php

示例4: filterRequiredPackages

 private function filterRequiredPackages(RepositoryInterface $repo, PackageInterface $package, $bucket = array())
 {
     $requires = array_keys($package->getRequires());
     $packageListNames = array_keys($bucket);
     $packages = array_filter($repo->getPackages(), function ($package) use($requires, $packageListNames) {
         return in_array($package->getName(), $requires) && !in_array($package->getName(), $packageListNames);
     });
     $bucket = $this->appendPackages($packages, $bucket);
     foreach ($packages as $package) {
         $bucket = $this->filterRequiredPackages($repo, $package, $bucket);
     }
     return $bucket;
 }
开发者ID:VicDeo,项目名称:poc,代码行数:13,代码来源:LicensesCommand.php

示例5: setUp

 public function setUp()
 {
     $this->composerMock = $this->getMockBuilder(Composer::class)->disableOriginalConstructor()->getMock();
     $this->lockerMock = $this->getMockBuilder(Locker::class)->disableOriginalConstructor()->getMock();
     $this->lockerRepositoryMock = $this->getMockForAbstractClass(\Composer\Repository\RepositoryInterface::class);
     $this->packageMock = $this->getMockForAbstractClass(\Composer\Package\CompletePackageInterface::class);
     $this->lockerMock->method('getLockedRepository')->willReturn($this->lockerRepositoryMock);
     $this->packageMock->method('getType')->willReturn('metapackage');
     $this->packageMock->method('getPrettyName')->willReturn('magento/product-test-package-name');
     $this->packageMock->method('getName')->willReturn('magento/product-test-package-name');
     $this->packageMock->method('getPrettyVersion')->willReturn('123.456.789');
     $this->lockerRepositoryMock->method('getPackages')->willReturn([$this->packageMock]);
     $objectManager = new ObjectManager($this);
     $this->composerInformation = $objectManager->getObject(\Magento\Framework\Composer\ComposerInformation::class, ['composer' => $this->composerMock, 'locker' => $this->lockerMock]);
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:15,代码来源:ComposerInformationTest.php

示例6: addRepository

 /**
  * Adds a repository and its packages to this package pool
  *
  * @param RepositoryInterface $repo        A package repository
  * @param array               $rootAliases
  */
 public function addRepository(RepositoryInterface $repo, $rootAliases = array())
 {
     if ($repo instanceof CompositeRepository) {
         $repos = $repo->getRepositories();
     } else {
         $repos = array($repo);
     }
     foreach ($repos as $repo) {
         $this->repositories[] = $repo;
         $exempt = $repo instanceof PlatformRepository || $repo instanceof InstalledRepositoryInterface;
         if ($repo instanceof ComposerRepository && $repo->hasProviders()) {
             $this->providerRepos[] = $repo;
             $repo->setRootAliases($rootAliases);
             $repo->resetPackageIds();
         } else {
             foreach ($repo->getPackages() as $package) {
                 $names = $package->getNames();
                 $stability = $package->getStability();
                 if ($exempt || $this->isPackageAcceptable($names, $stability)) {
                     $package->setId($this->id++);
                     $this->packages[] = $package;
                     $this->packageByExactName[$package->getName()][$package->id] = $package;
                     foreach ($names as $provided) {
                         $this->packageByName[$provided][] = $package;
                     }
                     // handle root package aliases
                     $name = $package->getName();
                     if (isset($rootAliases[$name][$package->getVersion()])) {
                         $alias = $rootAliases[$name][$package->getVersion()];
                         if ($package instanceof AliasPackage) {
                             $package = $package->getAliasOf();
                         }
                         $aliasPackage = new AliasPackage($package, $alias['alias_normalized'], $alias['alias']);
                         $aliasPackage->setRootPackageAlias(true);
                         $aliasPackage->setId($this->id++);
                         $package->getRepository()->addPackage($aliasPackage);
                         $this->packages[] = $aliasPackage;
                         $this->packageByExactName[$aliasPackage->getName()][$aliasPackage->id] = $aliasPackage;
                         foreach ($aliasPackage->getNames() as $name) {
                             $this->packageByName[$name][] = $aliasPackage;
                         }
                     }
                 }
             }
         }
     }
 }
开发者ID:zqcloveping,项目名称:pagekit,代码行数:53,代码来源:Pool.php

示例7: output

 /**
  * Output suggested packages.
  * Do not list the ones already installed if installed repository provided.
  *
  * @param  RepositoryInterface       $installedRepo Installed packages
  * @return SuggestedPackagesReporter
  */
 public function output(RepositoryInterface $installedRepo = null)
 {
     $suggestedPackages = $this->getPackages();
     $installedPackages = array();
     if (null !== $installedRepo && !empty($suggestedPackages)) {
         foreach ($installedRepo->getPackages() as $package) {
             $installedPackages = array_merge($installedPackages, $package->getNames());
         }
     }
     foreach ($suggestedPackages as $suggestion) {
         if (in_array($suggestion['target'], $installedPackages)) {
             continue;
         }
         $this->io->writeError(sprintf('%s suggests installing %s (%s)', $suggestion['source'], $suggestion['target'], $suggestion['reason']));
     }
     return $this;
 }
开发者ID:neon64,项目名称:composer,代码行数:24,代码来源:SuggestedPackagesReporter.php

示例8: addRepository

 public function addRepository(RepositoryInterface $repository)
 {
     if ($repository instanceof self) {
         foreach ($repository->getRepositories() as $repo) {
             $this->addRepository($repo);
         }
     } else {
         $this->repositories[] = $repository;
     }
 }
开发者ID:itillawarra,项目名称:cmfive,代码行数:10,代码来源:CompositeRepository.php

示例9: collectData

 public function collectData(RepositoryInterface $repo)
 {
     $puzzleData = [];
     foreach ($repo->getPackages() as $package) {
         /** @var Package $package */
         $extra = $package->getExtra();
         if (!empty($extra["downsider-puzzle-di"]) && is_array($extra["downsider-puzzle-di"])) {
             foreach ($extra["downsider-puzzle-di"] as $key => $config) {
                 if ($key == (string) (int) $key) {
                     continue;
                 }
                 if (!array_key_exists($key, $puzzleData)) {
                     $puzzleData[$key] = array();
                 }
                 $puzzleConfig = ["name" => $package->getName(), "path" => $this->installationManager->getInstallPath($package) . "/" . $config["path"]];
                 if (!empty($config["alias"])) {
                     $puzzleConfig["alias"] = $config["alias"];
                 }
                 $puzzleData[$key][] = $puzzleConfig;
             }
         }
     }
     return $puzzleData;
 }
开发者ID:downsider,项目名称:puzzle-di,代码行数:24,代码来源:PuzzleDataCollector.php

示例10: addRepository

 /**
  * Adds a repository and its packages to this package pool
  *
  * @param RepositoryInterface $repo A package repository
  */
 public function addRepository(RepositoryInterface $repo)
 {
     if ($repo instanceof CompositeRepository) {
         $repos = $repo->getRepositories();
     } else {
         $repos = array($repo);
     }
     $id = count($this->packages) + 1;
     foreach ($repos as $repo) {
         $this->repositories[] = $repo;
         $exempt = $repo instanceof PlatformRepository || $repo instanceof InstalledRepositoryInterface;
         foreach ($repo->getPackages() as $package) {
             $name = $package->getName();
             $stability = $package->getStability();
             if ($exempt || !isset($this->stabilityFlags[$name]) && isset($this->acceptableStabilities[$stability]) || isset($this->stabilityFlags[$name]) && BasePackage::$stabilities[$stability] <= $this->stabilityFlags[$name]) {
                 $package->setId($id++);
                 $this->packages[] = $package;
                 foreach ($package->getNames() as $name) {
                     $this->packageByName[$name][] = $package;
                 }
             }
         }
     }
 }
开发者ID:nickl-,项目名称:composer,代码行数:29,代码来源:Pool.php

示例11: dump

    public function dump(Config $config, RepositoryInterface $localRepo, PackageInterface $mainPackage, InstallationManager $installationManager, $targetDir, $scanPsr0Packages = false, $suffix = '')
    {
        $filesystem = new Filesystem();
        $filesystem->ensureDirectoryExists($config->get('vendor-dir'));
        $vendorPath = strtr(realpath($config->get('vendor-dir')), '\\', '/');
        $targetDir = $vendorPath . '/' . $targetDir;
        $filesystem->ensureDirectoryExists($targetDir);
        $relVendorPath = $filesystem->findShortestPath(getcwd(), $vendorPath, true);
        $vendorPathCode = $filesystem->findShortestPathCode(realpath($targetDir), $vendorPath, true);
        $vendorPathToTargetDirCode = $filesystem->findShortestPathCode($vendorPath, realpath($targetDir), true);
        $appBaseDirCode = $filesystem->findShortestPathCode($vendorPath, getcwd(), true);
        $appBaseDirCode = str_replace('__DIR__', '$vendorDir', $appBaseDirCode);
        $namespacesFile = <<<EOF
<?php

// autoload_namespaces.php generated by Composer

\$vendorDir = {$vendorPathCode};
\$baseDir = {$appBaseDirCode};

return array(

EOF;
        $packageMap = $this->buildPackageMap($installationManager, $mainPackage, $localRepo->getPackages());
        $autoloads = $this->parseAutoloads($packageMap);
        foreach ($autoloads['psr-0'] as $namespace => $paths) {
            $exportedPaths = array();
            foreach ($paths as $path) {
                $exportedPaths[] = $this->getPathCode($filesystem, $relVendorPath, $vendorPath, $path);
            }
            $exportedPrefix = var_export($namespace, true);
            $namespacesFile .= "    {$exportedPrefix} => ";
            if (count($exportedPaths) > 1) {
                $namespacesFile .= "array(" . implode(', ', $exportedPaths) . "),\n";
            } else {
                $namespacesFile .= $exportedPaths[0] . ",\n";
            }
        }
        $namespacesFile .= ");\n";
        $classmapFile = <<<EOF
<?php

// autoload_classmap.php generated by Composer

\$vendorDir = {$vendorPathCode};
\$baseDir = {$appBaseDirCode};

return array(

EOF;
        // add custom psr-0 autoloading if the root package has a target dir
        $targetDirLoader = null;
        $mainAutoload = $mainPackage->getAutoload();
        if ($mainPackage->getTargetDir() && !empty($mainAutoload['psr-0'])) {
            $levels = count(explode('/', trim(strtr($mainPackage->getTargetDir(), '\\', '/'), '/')));
            $prefixes = implode(', ', array_map(function ($prefix) {
                return var_export($prefix, true);
            }, array_keys($mainAutoload['psr-0'])));
            $baseDirFromTargetDirCode = $filesystem->findShortestPathCode($targetDir, getcwd(), true);
            $targetDirLoader = <<<EOF

    public static function autoload(\$class)
    {
        \$dir = {$baseDirFromTargetDirCode} . '/';
        \$prefixes = array({$prefixes});
        foreach (\$prefixes as \$prefix) {
            if (0 !== strpos(\$class, \$prefix)) {
                continue;
            }
            \$path = \$dir . implode('/', array_slice(explode('\\\\', \$class), {$levels})).'.php';
            if (!\$path = stream_resolve_include_path(\$path)) {
                return false;
            }
            require \$path;

            return true;
        }
    }

EOF;
        }
        // flatten array
        $classMap = array();
        $autoloads['classmap'] = new \RecursiveIteratorIterator(new \RecursiveArrayIterator($autoloads['classmap']));
        if ($scanPsr0Packages) {
            foreach ($autoloads['psr-0'] as $namespace => $paths) {
                foreach ($paths as $dir) {
                    $dir = $this->getPath($filesystem, $relVendorPath, $vendorPath, $dir);
                    $whitelist = sprintf('{%s/%s.+(?<!(?<!/)Test\\.php)$}', preg_quote(rtrim($dir, '/')), strpos($namespace, '_') === false ? preg_quote(strtr($namespace, '\\', '/')) : '');
                    foreach (ClassMapGenerator::createMap($dir, $whitelist) as $class => $path) {
                        if ('' === $namespace || 0 === strpos($class, $namespace)) {
                            $path = '/' . $filesystem->findShortestPath(getcwd(), $path, true);
                            if (!isset($classMap[$class])) {
                                $classMap[$class] = '$baseDir . ' . var_export($path, true) . ",\n";
                            }
                        }
                    }
                }
            }
        }
//.........这里部分代码省略.........
开发者ID:rufinus,项目名称:composer,代码行数:101,代码来源:AutoloadGenerator.php

示例12: markAliasUninstalled

 /**
  * Executes markAlias operation.
  *
  * @param RepositoryInterface           $repo      repository in which to check
  * @param MarkAliasUninstalledOperation $operation operation instance
  */
 public function markAliasUninstalled(RepositoryInterface $repo, MarkAliasUninstalledOperation $operation)
 {
     $package = $operation->getPackage();
     $repo->removePackage($package);
 }
开发者ID:nickelc,项目名称:composer,代码行数:11,代码来源:InstallationManager.php

示例13: 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

示例14: mapFromRepo

 protected function mapFromRepo(RepositoryInterface $repo)
 {
     $map = array();
     foreach ($repo->getPackages() as $package) {
         $map[$package->getId()] = true;
     }
     return $map;
 }
开发者ID:natxet,项目名称:composer,代码行数:8,代码来源:DefaultPolicyTest.php

示例15: calculateDependencyMap

 /**
  * Build dependency graph of installed packages.
  *
  * @param RepositoryInterface $repository
  *
  * @return array
  */
 protected function calculateDependencyMap(RepositoryInterface $repository, $inverted = false)
 {
     $dependencyMap = array();
     /** @var \Composer\Package\PackageInterface $package */
     foreach ($repository->getPackages() as $package) {
         $this->fillDependencyMap($package, $dependencyMap, $inverted);
     }
     return $dependencyMap;
 }
开发者ID:contao-community-alliance,项目名称:composer-client,代码行数:16,代码来源:AbstractController.php


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