mirror of
https://github.com/composer/composer
synced 2025-05-10 09:02:59 +00:00
Add home config key and use it to create the cache instance
This commit is contained in:
parent
28d0f4a7c8
commit
fc29487a2a
7 changed files with 40 additions and 33 deletions
|
@ -16,6 +16,7 @@ use Composer\Package\Loader\ArrayLoader;
|
|||
use Composer\Package\LinkConstraint\VersionConstraint;
|
||||
use Composer\Json\JsonFile;
|
||||
use Composer\Cache;
|
||||
use Composer\Config;
|
||||
use Composer\IO\IOInterface;
|
||||
use Composer\Util\RemoteFilesystem;
|
||||
|
||||
|
@ -29,20 +30,20 @@ class ComposerRepository extends ArrayRepository
|
|||
protected $packages;
|
||||
protected $cache;
|
||||
|
||||
public function __construct(array $config, IOInterface $io)
|
||||
public function __construct(array $repoConfig, IOInterface $io, Config $config)
|
||||
{
|
||||
if (!preg_match('{^\w+://}', $config['url'])) {
|
||||
if (!preg_match('{^\w+://}', $repoConfig['url'])) {
|
||||
// assume http as the default protocol
|
||||
$config['url'] = 'http://'.$config['url'];
|
||||
$repoConfig['url'] = 'http://'.$repoConfig['url'];
|
||||
}
|
||||
$config['url'] = rtrim($config['url'], '/');
|
||||
if (function_exists('filter_var') && !filter_var($config['url'], FILTER_VALIDATE_URL)) {
|
||||
throw new \UnexpectedValueException('Invalid url given for Composer repository: '.$config['url']);
|
||||
$repoConfig['url'] = rtrim($repoConfig['url'], '/');
|
||||
if (function_exists('filter_var') && !filter_var($repoConfig['url'], FILTER_VALIDATE_URL)) {
|
||||
throw new \UnexpectedValueException('Invalid url given for Composer repository: '.$repoConfig['url']);
|
||||
}
|
||||
|
||||
$this->url = $config['url'];
|
||||
$this->url = $repoConfig['url'];
|
||||
$this->io = $io;
|
||||
$this->cache = new Cache($io, preg_replace('{[^a-z0-9.]}', '-', $this->url));
|
||||
$this->cache = new Cache($io, $config->get('home').'/cache/'.preg_replace('{[^a-z0-9.]}', '-', $this->url));
|
||||
}
|
||||
|
||||
protected function initialize()
|
||||
|
|
|
@ -16,6 +16,7 @@ use Composer\IO\IOInterface;
|
|||
use Composer\Package\Loader\ArrayLoader;
|
||||
use Composer\Util\RemoteFilesystem;
|
||||
use Composer\Json\JsonFile;
|
||||
use Composer\Config;
|
||||
use Composer\Downloader\TransportException;
|
||||
|
||||
/**
|
||||
|
@ -31,18 +32,18 @@ class PearRepository extends ArrayRepository
|
|||
private $io;
|
||||
private $rfs;
|
||||
|
||||
public function __construct(array $config, IOInterface $io, RemoteFilesystem $rfs = null)
|
||||
public function __construct(array $repoConfig, IOInterface $io, Config $config, RemoteFilesystem $rfs = null)
|
||||
{
|
||||
if (!preg_match('{^https?://}', $config['url'])) {
|
||||
$config['url'] = 'http://'.$config['url'];
|
||||
if (!preg_match('{^https?://}', $repoConfig['url'])) {
|
||||
$repoConfig['url'] = 'http://'.$repoConfig['url'];
|
||||
}
|
||||
|
||||
if (function_exists('filter_var') && !filter_var($config['url'], FILTER_VALIDATE_URL)) {
|
||||
throw new \UnexpectedValueException('Invalid url given for PEAR repository: '.$config['url']);
|
||||
if (function_exists('filter_var') && !filter_var($repoConfig['url'], FILTER_VALIDATE_URL)) {
|
||||
throw new \UnexpectedValueException('Invalid url given for PEAR repository: '.$repoConfig['url']);
|
||||
}
|
||||
|
||||
$this->url = rtrim($config['url'], '/');
|
||||
$this->channel = !empty($config['channel']) ? $config['channel'] : null;
|
||||
$this->url = rtrim($repoConfig['url'], '/');
|
||||
$this->channel = !empty($repoConfig['channel']) ? $repoConfig['channel'] : null;
|
||||
$this->io = $io;
|
||||
$this->rfs = $rfs ?: new RemoteFilesystem($this->io);
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
namespace Composer\Repository;
|
||||
|
||||
use Composer\IO\IOInterface;
|
||||
use Composer\Config;
|
||||
|
||||
/**
|
||||
* Repositories manager.
|
||||
|
@ -27,10 +28,12 @@ class RepositoryManager
|
|||
private $repositories = array();
|
||||
private $repositoryClasses = array();
|
||||
private $io;
|
||||
private $config;
|
||||
|
||||
public function __construct(IOInterface $io)
|
||||
public function __construct(IOInterface $io, Config $config)
|
||||
{
|
||||
$this->io = $io;
|
||||
$this->config = $config;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -94,7 +97,7 @@ class RepositoryManager
|
|||
}
|
||||
|
||||
$class = $this->repositoryClasses[$type];
|
||||
return new $class($config, $this->io);
|
||||
return new $class($config, $this->io, $this->config);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -19,6 +19,7 @@ use Composer\Package\PackageInterface;
|
|||
use Composer\Package\AliasPackage;
|
||||
use Composer\Package\Loader\ArrayLoader;
|
||||
use Composer\IO\IOInterface;
|
||||
use Composer\Config;
|
||||
|
||||
/**
|
||||
* @author Jordi Boggiano <j.boggiano@seld.be>
|
||||
|
@ -32,7 +33,7 @@ class VcsRepository extends ArrayRepository
|
|||
protected $versionParser;
|
||||
protected $type;
|
||||
|
||||
public function __construct(array $config, IOInterface $io, array $drivers = null)
|
||||
public function __construct(array $repoConfig, IOInterface $io, Config $config = null, array $drivers = null)
|
||||
{
|
||||
$this->drivers = $drivers ?: array(
|
||||
'github' => 'Composer\Repository\Vcs\GitHubDriver',
|
||||
|
@ -43,9 +44,9 @@ class VcsRepository extends ArrayRepository
|
|||
'hg' => 'Composer\Repository\Vcs\HgDriver',
|
||||
);
|
||||
|
||||
$this->url = $config['url'];
|
||||
$this->url = $repoConfig['url'];
|
||||
$this->io = $io;
|
||||
$this->type = isset($config['type']) ? $config['type'] : 'vcs';
|
||||
$this->type = isset($repoConfig['type']) ? $repoConfig['type'] : 'vcs';
|
||||
$this->verbose = $io->isVerbose();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue