1
0
Fork 0

Minor fixes

pull/2993/merge
Jordi Boggiano 2013-08-19 01:20:34 +02:00
parent ba776c06ee
commit b39df32d4b
2 changed files with 21 additions and 19 deletions

View File

@ -582,17 +582,19 @@ class Package extends BasePackage
protected function getUrls($url, $mirrors, $ref, $type) protected function getUrls($url, $mirrors, $ref, $type)
{ {
$urls = array(); if (!$url) {
if ($url) { return array();
$urls[] = $url;
} }
$urls = array($url);
if ($mirrors) { if ($mirrors) {
foreach ($mirrors as $mirror) { foreach ($mirrors as $mirror) {
$mirrorUrl = ComposerMirror::processUrl($mirror['url'], $this->name, $this->version, $ref, $type); $mirrorUrl = ComposerMirror::processUrl($mirror['url'], $this->name, $this->version, $ref, $type);
if (!in_array($urls, $mirrorUrl)) {
$func = $mirror['preferred'] ? 'array_unshift' : 'array_push'; $func = $mirror['preferred'] ? 'array_unshift' : 'array_push';
$func($urls, $mirrorUrl); $func($urls, $mirrorUrl);
} }
} }
}
return $urls; return $urls;
} }

View File

@ -1,22 +1,22 @@
<?php <?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\Util; namespace Composer\Util;
/**
* Composer mirror utilities
*
* @author Jordi Boggiano <j.boggiano@seld.be>
*/
class ComposerMirror class ComposerMirror
{ {
public static function processUrl($mirrorUrl, $packageName, $version, $reference, $type) public static function processUrl($mirrorUrl, $packageName, $version, $reference, $type)