Refactor repositories configuration
parent
0cb02cf3ca
commit
44e76e06fc
|
@ -51,6 +51,7 @@ class Factory
|
||||||
// Configuration defaults
|
// Configuration defaults
|
||||||
$composerConfig = array(
|
$composerConfig = array(
|
||||||
'vendor-dir' => 'vendor',
|
'vendor-dir' => 'vendor',
|
||||||
|
'repositories' => array(),
|
||||||
);
|
);
|
||||||
|
|
||||||
$packageConfig = $file->read();
|
$packageConfig = $file->read();
|
||||||
|
@ -71,7 +72,13 @@ 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
|
||||||
if (!isset($packageConfig['repositories']['packagist']) || $packageConfig['repositories']['packagist'] !== false) {
|
$loadPackagist = true;
|
||||||
|
foreach ($packageConfig['repositories'] as $repo) {
|
||||||
|
if (isset($repo['packagist']) && $repo['packagist'] === false) {
|
||||||
|
$loadPackagist = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($loadPackagist) {
|
||||||
$this->addPackagistRepository($rm);
|
$this->addPackagistRepository($rm);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,14 +44,17 @@ class RootPackageLoader extends ArrayLoader
|
||||||
$package = parent::load($config);
|
$package = parent::load($config);
|
||||||
|
|
||||||
if (isset($config['repositories'])) {
|
if (isset($config['repositories'])) {
|
||||||
foreach ($config['repositories'] as $repoName => $repo) {
|
foreach ($config['repositories'] as $index => $repo) {
|
||||||
if (false === $repo && 'packagist' === $repoName) {
|
if (isset($repo['packagist']) && $repo['packagist'] === false) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!is_array($repo)) {
|
if (!is_array($repo)) {
|
||||||
throw new \UnexpectedValueException('Repository '.$repoName.' in '.$package->getPrettyName().' '.$package->getVersion().' should be an array, '.gettype($repo).' given');
|
throw new \UnexpectedValueException('Repository '.$index.' should be an array, '.gettype($repo).' given');
|
||||||
}
|
}
|
||||||
$repository = $this->manager->createRepository(key($repo), current($repo));
|
if (!isset($repo['type'])) {
|
||||||
|
throw new \UnexpectedValueException('Repository '.$index.' must have a type defined');
|
||||||
|
}
|
||||||
|
$repository = $this->manager->createRepository($repo['type'], $repo);
|
||||||
$this->manager->addRepository($repository);
|
$this->manager->addRepository($repository);
|
||||||
}
|
}
|
||||||
$package->setRepositories($config['repositories']);
|
$package->setRepositories($config['repositories']);
|
||||||
|
|
Loading…
Reference in New Issue