Added packagist repository as the last repository with the lowest priority
parent
2b08df5192
commit
9021c86237
|
@ -78,17 +78,7 @@ class Factory
|
||||||
$rm = $this->createRepositoryManager($io);
|
$rm = $this->createRepositoryManager($io);
|
||||||
|
|
||||||
// load default repository unless it's explicitly disabled
|
// load default repository unless it's explicitly disabled
|
||||||
$loadPackagist = true;
|
$packageConfig = $this->addPackagistRepository($packageConfig);
|
||||||
if (isset($packageConfig['repositories'])) {
|
|
||||||
foreach ($packageConfig['repositories'] as $repo) {
|
|
||||||
if (isset($repo['packagist']) && $repo['packagist'] === false) {
|
|
||||||
$loadPackagist = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ($loadPackagist) {
|
|
||||||
$this->addPackagistRepository($rm);
|
|
||||||
}
|
|
||||||
|
|
||||||
// load local repository
|
// load local repository
|
||||||
$this->addLocalRepository($rm, $vendorDir);
|
$this->addLocalRepository($rm, $vendorDir);
|
||||||
|
@ -134,9 +124,32 @@ class Factory
|
||||||
$rm->setLocalRepository(new Repository\InstalledFilesystemRepository(new JsonFile($vendorDir.'/.composer/installed.json')));
|
$rm->setLocalRepository(new Repository\InstalledFilesystemRepository(new JsonFile($vendorDir.'/.composer/installed.json')));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function addPackagistRepository(RepositoryManager $rm)
|
protected function addPackagistRepository(array $packageConfig)
|
||||||
{
|
{
|
||||||
$rm->addRepository(new Repository\ComposerRepository(array('url' => 'http://packagist.org')));
|
$loadPackagist = true;
|
||||||
|
$packagistConfig = array(
|
||||||
|
'type' => 'composer',
|
||||||
|
'url' => 'http://packagist.org'
|
||||||
|
);
|
||||||
|
if (isset($packageConfig['repositories'])) {
|
||||||
|
foreach ($packageConfig['repositories'] as $key => $repo) {
|
||||||
|
if (isset($repo['packagist'])) {
|
||||||
|
if (true === $repo['packagist']) {
|
||||||
|
$packageConfig['repositories'][$key] = $packagistConfig;
|
||||||
|
}
|
||||||
|
|
||||||
|
$loadPackagist = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$packageConfig['repositories'] = array();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($loadPackagist) {
|
||||||
|
$packageConfig['repositories'][] = $packagistConfig;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $packageConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function createDownloadManager(IOInterface $io)
|
protected function createDownloadManager(IOInterface $io)
|
||||||
|
|
|
@ -0,0 +1,65 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of Composer.
|
||||||
|
*
|
||||||
|
* (c) Nils Adermann <naderman@naderman.de>
|
||||||
|
* Jordi Boggiano <j.boggiano@seld.be>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Composer\Test;
|
||||||
|
|
||||||
|
use Composer\Factory;
|
||||||
|
|
||||||
|
class FactoryTest extends \PHPUnit_Framework_TestCase
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @dataProvider dataAddPackagistRepository
|
||||||
|
*/
|
||||||
|
public function testAddPackagistRepository($expected, $config)
|
||||||
|
{
|
||||||
|
$factory = new Factory();
|
||||||
|
|
||||||
|
$ref = new \ReflectionMethod($factory, 'addPackagistRepository');
|
||||||
|
$ref->setAccessible(true);
|
||||||
|
|
||||||
|
$this->assertEquals($expected, $ref->invoke($factory, $config));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function dataAddPackagistRepository()
|
||||||
|
{
|
||||||
|
$f = function() {
|
||||||
|
$repositories = func_get_args();
|
||||||
|
return array('repositories' => $repositories);
|
||||||
|
};
|
||||||
|
|
||||||
|
$data = array();
|
||||||
|
$data[] = array(
|
||||||
|
$f(array('type' => 'composer', 'url' => 'http://packagist.org')),
|
||||||
|
$f()
|
||||||
|
);
|
||||||
|
|
||||||
|
$data[] = array(
|
||||||
|
$f(array('packagist' => false)),
|
||||||
|
$f(array('packagist' => false))
|
||||||
|
);
|
||||||
|
|
||||||
|
$data[] = array(
|
||||||
|
$f(
|
||||||
|
array('type' => 'vcs', 'url' => 'git://github.com/composer/composer.git'),
|
||||||
|
array('type' => 'composer', 'url' => 'http://packagist.org'),
|
||||||
|
array('type' => 'pear', 'url' => 'http://pear.composer.org')
|
||||||
|
),
|
||||||
|
$f(
|
||||||
|
array('type' => 'vcs', 'url' => 'git://github.com/composer/composer.git'),
|
||||||
|
array('packagist' => true),
|
||||||
|
array('type' => 'pear', 'url' => 'http://pear.composer.org')
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue