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


PHP Config::getRepositories方法代码示例

本文整理汇总了PHP中Composer\Config::getRepositories方法的典型用法代码示例。如果您正苦于以下问题:PHP Config::getRepositories方法的具体用法?PHP Config::getRepositories怎么用?PHP Config::getRepositories使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Composer\Config的用法示例。


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

示例1: load

 public function load(array $config, $class = 'Composer\\Package\\RootPackage')
 {
     if (!isset($config['name'])) {
         $config['name'] = '__root__';
     }
     $autoVersioned = false;
     if (!isset($config['version'])) {
         // override with env var if available
         if (getenv('COMPOSER_ROOT_VERSION')) {
             $version = getenv('COMPOSER_ROOT_VERSION');
         } else {
             $version = $this->versionGuesser->guessVersion($config, getcwd());
         }
         if (!$version) {
             $version = '1.0.0';
             $autoVersioned = true;
         }
         $config['version'] = $version;
     }
     $realPackage = $package = parent::load($config, $class);
     if ($realPackage instanceof AliasPackage) {
         $realPackage = $package->getAliasOf();
     }
     if ($autoVersioned) {
         $realPackage->replaceVersion($realPackage->getVersion(), 'No version set (parsed as 1.0.0)');
     }
     if (isset($config['minimum-stability'])) {
         $realPackage->setMinimumStability(VersionParser::normalizeStability($config['minimum-stability']));
     }
     $aliases = array();
     $stabilityFlags = array();
     $references = array();
     foreach (array('require', 'require-dev') as $linkType) {
         if (isset($config[$linkType])) {
             $linkInfo = BasePackage::$supportedLinkTypes[$linkType];
             $method = 'get' . ucfirst($linkInfo['method']);
             $links = array();
             foreach ($realPackage->{$method}() as $link) {
                 $links[$link->getTarget()] = $link->getConstraint()->getPrettyString();
             }
             $aliases = $this->extractAliases($links, $aliases);
             $stabilityFlags = $this->extractStabilityFlags($links, $stabilityFlags, $realPackage->getMinimumStability());
             $references = $this->extractReferences($links, $references);
         }
     }
     $realPackage->setAliases($aliases);
     $realPackage->setStabilityFlags($stabilityFlags);
     $realPackage->setReferences($references);
     if (isset($config['prefer-stable'])) {
         $realPackage->setPreferStable((bool) $config['prefer-stable']);
     }
     $repos = Factory::createDefaultRepositories(null, $this->config, $this->manager);
     foreach ($repos as $repo) {
         $this->manager->addRepository($repo);
     }
     $realPackage->setRepositories($this->config->getRepositories());
     return $package;
 }
开发者ID:neoFaster,项目名称:composer,代码行数:58,代码来源:RootPackageLoader.php

示例2: testAddPackagistRepository

 /**
  * @dataProvider dataAddPackagistRepository
  */
 public function testAddPackagistRepository($expected, $localConfig, $systemConfig = null)
 {
     $config = new Config(false);
     if ($systemConfig) {
         $config->merge(array('repositories' => $systemConfig));
     }
     $config->merge(array('repositories' => $localConfig));
     $this->assertEquals($expected, $config->getRepositories());
 }
开发者ID:hanovruslan,项目名称:composer,代码行数:12,代码来源:ConfigTest.php

示例3: getRepositories

 /**
  * @return array
  */
 public function getRepositories()
 {
     // Because the Composer devs don't appear to understand what subclassing
     // is, we need to override this here rather than using
     // $this->repositories directly.
     $repos = parent::getRepositories();
     // Add wpackagist by default
     $wp_repos = array('wpackagist' => array('type' => 'composer', 'url' => 'http://wpackagist.org'));
     return array_merge($wp_repos, $repos);
 }
开发者ID:rmccue,项目名称:Courier,代码行数:13,代码来源:class-config.php

示例4: load

 /**
  * @param  array                $config package data
  * @param  string               $class  FQCN to be instantiated
  * @param  string               $cwd    cwd of the root package to be used to guess the version if it is not provided
  * @return RootPackageInterface
  */
 public function load(array $config, $class = 'Composer\\Package\\RootPackage', $cwd = null)
 {
     if (!isset($config['name'])) {
         $config['name'] = '__root__';
     }
     $autoVersioned = false;
     if (!isset($config['version'])) {
         // override with env var if available
         if (getenv('COMPOSER_ROOT_VERSION')) {
             $version = getenv('COMPOSER_ROOT_VERSION');
             $commit = null;
         } else {
             $versionData = $this->versionGuesser->guessVersion($config, $cwd ?: getcwd());
             $version = $versionData['version'];
             $commit = $versionData['commit'];
         }
         if (!$version) {
             $version = '1.0.0';
             $autoVersioned = true;
         }
         $config['version'] = $version;
         if ($commit) {
             $config['source'] = array('type' => '', 'url' => '', 'reference' => $commit);
             $config['dist'] = array('type' => '', 'url' => '', 'reference' => $commit);
         }
     }
     $realPackage = $package = parent::load($config, $class);
     if ($realPackage instanceof AliasPackage) {
         $realPackage = $package->getAliasOf();
     }
     if ($autoVersioned) {
         $realPackage->replaceVersion($realPackage->getVersion(), 'No version set (parsed as 1.0.0)');
     }
     if (isset($config['minimum-stability'])) {
         $realPackage->setMinimumStability(VersionParser::normalizeStability($config['minimum-stability']));
     }
     $aliases = array();
     $stabilityFlags = array();
     $references = array();
     foreach (array('require', 'require-dev') as $linkType) {
         if (isset($config[$linkType])) {
             $linkInfo = BasePackage::$supportedLinkTypes[$linkType];
             $method = 'get' . ucfirst($linkInfo['method']);
             $links = array();
             foreach ($realPackage->{$method}() as $link) {
                 $links[$link->getTarget()] = $link->getConstraint()->getPrettyString();
             }
             $aliases = $this->extractAliases($links, $aliases);
             $stabilityFlags = $this->extractStabilityFlags($links, $stabilityFlags, $realPackage->getMinimumStability());
             $references = $this->extractReferences($links, $references);
         }
     }
     if (isset($links[$config['name']])) {
         throw new \InvalidArgumentException(sprintf('Root package \'%s\' cannot require itself in its composer.json' . PHP_EOL . 'Did you accidentally name your root package after an external package?', $config['name']));
     }
     $realPackage->setAliases($aliases);
     $realPackage->setStabilityFlags($stabilityFlags);
     $realPackage->setReferences($references);
     if (isset($config['prefer-stable'])) {
         $realPackage->setPreferStable((bool) $config['prefer-stable']);
     }
     if (isset($config['config'])) {
         $realPackage->setConfig($config['config']);
     }
     $repos = RepositoryFactory::defaultRepos(null, $this->config, $this->manager);
     foreach ($repos as $repo) {
         $this->manager->addRepository($repo);
     }
     $realPackage->setRepositories($this->config->getRepositories());
     return $package;
 }
开发者ID:neon64,项目名称:composer,代码行数:77,代码来源:RootPackageLoader.php


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