本文整理匯總了PHP中Composer\Repository\RepositoryManager::addRepository方法的典型用法代碼示例。如果您正苦於以下問題:PHP RepositoryManager::addRepository方法的具體用法?PHP RepositoryManager::addRepository怎麽用?PHP RepositoryManager::addRepository使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Composer\Repository\RepositoryManager
的用法示例。
在下文中一共展示了RepositoryManager::addRepository方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testInstaller
/**
* @dataProvider provideInstaller
*/
public function testInstaller(PackageInterface $rootPackage, $repositories, array $options)
{
$io = $this->getMock('Composer\\IO\\IOInterface');
$downloadManager = $this->getMock('Composer\\Downloader\\DownloadManager');
$config = $this->getMock('Composer\\Config');
$repositoryManager = new RepositoryManager($io, $config);
$repositoryManager->setLocalRepository(new WritableRepositoryMock());
$repositoryManager->setLocalDevRepository(new WritableRepositoryMock());
if (!is_array($repositories)) {
$repositories = array($repositories);
}
foreach ($repositories as $repository) {
$repositoryManager->addRepository($repository);
}
$locker = $this->getMockBuilder('Composer\\Package\\Locker')->disableOriginalConstructor()->getMock();
$installationManager = new InstallationManagerMock();
$eventDispatcher = $this->getMockBuilder('Composer\\Script\\EventDispatcher')->disableOriginalConstructor()->getMock();
$autoloadGenerator = $this->getMock('Composer\\Autoload\\AutoloadGenerator');
$installer = new Installer($io, $config, clone $rootPackage, $downloadManager, $repositoryManager, $locker, $installationManager, $eventDispatcher, $autoloadGenerator);
$result = $installer->run();
$this->assertTrue($result);
$expectedInstalled = isset($options['install']) ? $options['install'] : array();
$expectedUpdated = isset($options['update']) ? $options['update'] : array();
$expectedUninstalled = isset($options['uninstall']) ? $options['uninstall'] : array();
$installed = $installationManager->getInstalledPackages();
$this->assertSame($expectedInstalled, $installed);
$updated = $installationManager->getUpdatedPackages();
$this->assertSame($expectedUpdated, $updated);
$uninstalled = $installationManager->getUninstalledPackages();
$this->assertSame($expectedUninstalled, $uninstalled);
}
示例2: 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;
}
示例3: addRegistryRepositories
/**
* Adds asset registry repositories.
*
* @param RepositoryManager $rm
* @param VcsPackageFilter $filter
* @param array $extra
*/
public static function addRegistryRepositories(RepositoryManager $rm, VcsPackageFilter $filter, array $extra)
{
$opts = array_key_exists('asset-registry-options', $extra) ? $extra['asset-registry-options'] : array();
foreach (Assets::getRegistries() as $assetType => $registryClass) {
$config = array('repository-manager' => $rm, 'vcs-package-filter' => $filter, 'asset-options' => static::createAssetOptions($opts, $assetType));
$rm->setRepositoryClass($assetType, $registryClass);
$rm->addRepository($rm->createRepository($assetType, $config));
}
}
示例4: testPrepend
public function testPrepend()
{
$rm = new RepositoryManager($this->getMock('Composer\\IO\\IOInterface'), $this->getMock('Composer\\Config'), $this->getMockBuilder('Composer\\EventDispatcher\\EventDispatcher')->disableOriginalConstructor()->getMock());
$repository1 = $this->getMock('Composer\\Repository\\RepositoryInterface');
$repository2 = $this->getMock('Composer\\Repository\\RepositoryInterface');
$rm->addRepository($repository1);
$rm->prependRepository($repository2);
$this->assertEquals(array($repository2, $repository1), $rm->getRepositories());
}
示例5: addRepositoryInstance
/**
* Add repository instance.
*
* @param IOInterface $io The IO instance
* @param RepositoryManager $rm The repository mamanger
* @param array $repos The list of already repository added (passed by reference)
* @param string $name The name of the new repository
* @param RepositoryInterface $repo The repository instance
* @param Pool|null $pool The pool
*/
public static function addRepositoryInstance(IOInterface $io, RepositoryManager $rm, array &$repos, $name, RepositoryInterface $repo, Pool $pool = null)
{
if (!isset($repos[$name])) {
static::writeAddRepository($io, $name);
$repos[$name] = $repo;
$rm->addRepository($repo);
if (null !== $pool) {
$pool->addRepository($repo);
}
}
}
示例6: testOverridingVcsRepositoryConfig
public function testOverridingVcsRepositoryConfig()
{
$name = $this->getType() . '-asset/foobar';
$rfs = $this->replaceRegistryRfsByMock();
$rfs->expects($this->any())->method('getContents')->will($this->returnValue(json_encode($this->getMockPackageForVcsConfig())));
$repo = $this->getMockBuilder('Fxp\\Composer\\AssetPlugin\\Repository\\AssetVcsRepository')->disableOriginalConstructor()->getMock();
$repo->expects($this->any())->method('getComposerPackageName')->will($this->returnValue($name));
/* @var AssetVcsRepository $repo */
$this->rm->addRepository($repo);
$this->assertCount(0, $this->registry->whatProvides($this->pool, $name));
}
示例7: addRepository
/**
* @param RepositoryManager $rm The repository mamanger
* @param array $repos The list of already repository added (passed by reference)
* @param string $name The name of the new repository
* @param array $repoConfig The config of the new repository
* @param Pool|null $pool The pool
*/
public static function addRepository(RepositoryManager $rm, array &$repos, $name, array $repoConfig, Pool $pool = null)
{
if (!isset($repos[$name])) {
$repo = $rm->createRepository($repoConfig['type'], $repoConfig);
$repos[$name] = $repo;
$rm->addRepository($repo);
if (null !== $pool) {
$pool->addRepository($repo);
}
}
}
示例8: __construct
public function __construct()
{
require_once ABSPATH . 'wp-admin/includes/plugin.php';
$this->config = new Config();
$this->repositoryManager = $rm = new RepositoryManager(new NullIO(), $this->config);
$rm->setRepositoryClass('composer', 'Composer\\Repository\\ComposerRepository');
$rm->setRepositoryClass('vcs', 'Composer\\Repository\\VcsRepository');
$rm->setRepositoryClass('package', 'Composer\\Repository\\PackageRepository');
$rm->setRepositoryClass('pear', 'Composer\\Repository\\PearRepository');
$rm->setRepositoryClass('git', 'Composer\\Repository\\VcsRepository');
$rm->setRepositoryClass('svn', 'Composer\\Repository\\VcsRepository');
$rm->setRepositoryClass('perforce', 'Composer\\Repository\\VcsRepository');
$rm->setRepositoryClass('hg', 'Composer\\Repository\\VcsRepository');
$rm->setRepositoryClass('artifact', 'Composer\\Repository\\ArtifactRepository');
$home = $this->getHomeDir();
$cache = $this->getCacheDir($home);
$this->config->merge(array('config' => array('home' => $home, 'cache-dir' => $cache)));
foreach ($this->config->getRepositories() as $index => $repo) {
if (!is_array($repo)) {
throw new \UnexpectedValueException('Repository ' . $index . ' (' . json_encode($repo) . ') should be an array, ' . gettype($repo) . ' given');
}
if (!isset($repo['type'])) {
throw new \UnexpectedValueException('Repository ' . $index . ' (' . json_encode($repo) . ') must have a type defined');
}
$name = is_int($index) && isset($repo['url']) ? preg_replace('{^https?://}i', '', $repo['url']) : $index;
while (isset($repos[$name])) {
$name .= '2';
}
$repo_object = $rm->createRepository($repo['type'], $repo);
$rm->addRepository($repo_object);
}
}
示例9: addPackagistRepository
protected function addPackagistRepository(RepositoryManager $rm)
{
$rm->addRepository(new Repository\ComposerRepository(array('url' => 'http://packagist.org')));
}
示例10: 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;
}