[pear-prefix] add a pear-{channel}/ prefix to PearRepository packages
parent
9ba0505751
commit
06f1ecf83a
|
@ -22,6 +22,7 @@ use Composer\Util\StreamContextFactory;
|
|||
class PearRepository extends ArrayRepository
|
||||
{
|
||||
private $url;
|
||||
private $channel;
|
||||
private $streamContext;
|
||||
|
||||
public function __construct(array $config)
|
||||
|
@ -29,11 +30,14 @@ class PearRepository extends ArrayRepository
|
|||
if (!preg_match('{^https?://}', $config['url'])) {
|
||||
$config['url'] = 'http://'.$config['url'];
|
||||
}
|
||||
|
||||
if (!filter_var($config['url'], FILTER_VALIDATE_URL)) {
|
||||
throw new \UnexpectedValueException('Invalid url given for PEAR repository: '.$config['url']);
|
||||
}
|
||||
|
||||
$this->url = rtrim($config['url'], '/');
|
||||
|
||||
$this->channel = !empty($config['channel']) ? $config['channel'] : null;
|
||||
}
|
||||
|
||||
protected function initialize()
|
||||
|
@ -50,6 +54,12 @@ class PearRepository extends ArrayRepository
|
|||
|
||||
protected function fetchFromServer()
|
||||
{
|
||||
if (!$this->channel) {
|
||||
$channelXML = $this->requestXml($this->url . "/channel.xml");
|
||||
$this->channel = $channelXML->getElementsByTagName("suggestedalias")->item(0)->nodeValue
|
||||
?: $channelXML->getElementsByTagName("name")->item(0)->nodeValue;
|
||||
}
|
||||
|
||||
$categoryXML = $this->requestXml($this->url . "/rest/c/categories.xml");
|
||||
$categories = $categoryXML->getElementsByTagName("c");
|
||||
|
||||
|
@ -80,7 +90,7 @@ class PearRepository extends ArrayRepository
|
|||
$packages = $packagesXML->getElementsByTagName('p');
|
||||
$loader = new ArrayLoader();
|
||||
foreach ($packages as $package) {
|
||||
$packageName = $package->nodeValue;
|
||||
$packageName = 'pear-'.$this->channel.'/'.$package->nodeValue;
|
||||
|
||||
$packageLink = $package->getAttribute('xlink:href');
|
||||
$releaseLink = $this->url . str_replace("/rest/p/", "/rest/r/", $packageLink);
|
||||
|
@ -219,7 +229,7 @@ class PearRepository extends ArrayRepository
|
|||
foreach ($informations as $information) {
|
||||
$package = $information->getElementsByTagName('p')->item(0);
|
||||
|
||||
$packageName = $package->getElementsByTagName('n')->item(0)->nodeValue;
|
||||
$packageName = 'pear-'.$this->channel.'/'.$package->getElementsByTagName('n')->item(0)->nodeValue;
|
||||
$packageData = array(
|
||||
'name' => $packageName,
|
||||
'type' => 'library'
|
||||
|
|
Loading…
Reference in New Issue