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