Remove WrapperRepository in favor of PlatformRepository wrapping the local repo
parent
b9114e16be
commit
e5907a3431
|
@ -12,11 +12,7 @@ use Composer\Console\Application as ComposerApplication;
|
||||||
|
|
||||||
// initialize repository manager
|
// initialize repository manager
|
||||||
$rm = new Repository\RepositoryManager();
|
$rm = new Repository\RepositoryManager();
|
||||||
$localRepository = new Repository\WrapperRepository(array(
|
$rm->setLocalRepository(new Repository\PlatformRepository(new Repository\FilesystemRepository('.composer/installed.json')));
|
||||||
new Repository\ArrayRepository('.composer/installed.json'),
|
|
||||||
new Repository\PlatformRepository(),
|
|
||||||
));
|
|
||||||
$rm->setLocalRepository($localRepository);
|
|
||||||
$rm->setRepository('Packagist', new Repository\ComposerRepository('http://packagist.org'));
|
$rm->setRepository('Packagist', new Repository\ComposerRepository('http://packagist.org'));
|
||||||
|
|
||||||
// initialize download manager
|
// initialize download manager
|
||||||
|
|
|
@ -14,13 +14,21 @@ namespace Composer\Repository;
|
||||||
|
|
||||||
use Composer\Package\MemoryPackage;
|
use Composer\Package\MemoryPackage;
|
||||||
use Composer\Package\BasePackage;
|
use Composer\Package\BasePackage;
|
||||||
|
use Composer\Package\PackageInterface;
|
||||||
use Composer\Package\Version\VersionParser;
|
use Composer\Package\Version\VersionParser;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Jordi Boggiano <j.boggiano@seld.be>
|
* @author Jordi Boggiano <j.boggiano@seld.be>
|
||||||
*/
|
*/
|
||||||
class PlatformRepository extends ArrayRepository
|
class PlatformRepository extends ArrayRepository implements WritableRepositoryInterface
|
||||||
{
|
{
|
||||||
|
private $localRepository;
|
||||||
|
|
||||||
|
public function __construct(WritableRepositoryInterface $localRepository)
|
||||||
|
{
|
||||||
|
$this->localRepository = $localRepository;
|
||||||
|
}
|
||||||
|
|
||||||
protected function initialize()
|
protected function initialize()
|
||||||
{
|
{
|
||||||
parent::initialize();
|
parent::initialize();
|
||||||
|
@ -34,7 +42,7 @@ class PlatformRepository extends ArrayRepository
|
||||||
}
|
}
|
||||||
|
|
||||||
$php = new MemoryPackage('php', $version['version'], $version['type']);
|
$php = new MemoryPackage('php', $version['version'], $version['type']);
|
||||||
$this->addPackage($php);
|
parent::addPackage($php);
|
||||||
|
|
||||||
foreach (get_loaded_extensions() as $ext) {
|
foreach (get_loaded_extensions() as $ext) {
|
||||||
if (in_array($ext, array('standard', 'Core'))) {
|
if (in_array($ext, array('standard', 'Core'))) {
|
||||||
|
@ -49,7 +57,36 @@ class PlatformRepository extends ArrayRepository
|
||||||
}
|
}
|
||||||
|
|
||||||
$ext = new MemoryPackage('ext/'.strtolower($ext), $version['version'], $version['type']);
|
$ext = new MemoryPackage('ext/'.strtolower($ext), $version['version'], $version['type']);
|
||||||
$this->addPackage($ext);
|
parent::addPackage($ext);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getPackages()
|
||||||
|
{
|
||||||
|
return array_merge(parent::getPackages(), $this->localRepository->getPackages());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public function addPackage(PackageInterface $package)
|
||||||
|
{
|
||||||
|
$this->localRepository->addPackage($package);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public function removePackage(PackageInterface $package)
|
||||||
|
{
|
||||||
|
$this->localRepository->removePackage($package);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public function write()
|
||||||
|
{
|
||||||
|
$this->localRepository->write();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,64 +0,0 @@
|
||||||
<?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\Repository;
|
|
||||||
|
|
||||||
use Composer\Package\PackageInterface;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Jordi Boggiano <j.boggiano@seld.be>
|
|
||||||
*/
|
|
||||||
class WrapperRepository extends ArrayRepository implements WritableRepositoryInterface
|
|
||||||
{
|
|
||||||
private $repositories;
|
|
||||||
|
|
||||||
public function __construct(array $repositories)
|
|
||||||
{
|
|
||||||
$this->repositories = $repositories;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function initialize()
|
|
||||||
{
|
|
||||||
parent::initialize();
|
|
||||||
|
|
||||||
foreach ($this->repositories as $repo) {
|
|
||||||
foreach ($repo->getPackages() as $package) {
|
|
||||||
$this->packages[] = $package;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
public function addPackage(PackageInterface $package)
|
|
||||||
{
|
|
||||||
throw new \LogicException('Can not add packages to a wrapper repository');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
public function removePackage(PackageInterface $package)
|
|
||||||
{
|
|
||||||
throw new \LogicException('Can not remove packages to a wrapper repository');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function write()
|
|
||||||
{
|
|
||||||
foreach ($this->repositories as $repo) {
|
|
||||||
if ($repo instanceof WritableRepositoryInterface) {
|
|
||||||
$repo->write();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue