2011-04-17 22:14:44 +00:00
|
|
|
<?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;
|
|
|
|
|
2011-09-17 11:18:34 +00:00
|
|
|
use Composer\Installer\InstallerInterface;
|
2011-04-17 22:14:44 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @author Jordi Boggiano <j.boggiano@seld.be>
|
2011-09-16 19:14:06 +00:00
|
|
|
* @author Konstantin Kudryashiv <ever.zet@gmail.com>
|
2011-04-17 22:14:44 +00:00
|
|
|
*/
|
|
|
|
class Composer
|
|
|
|
{
|
2011-09-14 12:57:40 +00:00
|
|
|
const VERSION = '1.0.0-DEV';
|
|
|
|
|
2011-09-16 19:14:06 +00:00
|
|
|
private $repositories = array();
|
|
|
|
private $installers = array();
|
2011-04-17 22:14:44 +00:00
|
|
|
|
2011-09-16 19:14:06 +00:00
|
|
|
public function setInstaller($type, InstallerInterface $installer = null)
|
2011-04-17 22:14:44 +00:00
|
|
|
{
|
2011-09-16 19:14:06 +00:00
|
|
|
if (null === $installer) {
|
|
|
|
unset($this->installers[$type]);
|
2011-04-17 22:14:44 +00:00
|
|
|
|
2011-09-16 19:14:06 +00:00
|
|
|
return;
|
2011-04-17 22:14:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$this->installers[$type] = $installer;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getInstaller($type)
|
|
|
|
{
|
|
|
|
if (!isset($this->installers[$type])) {
|
|
|
|
throw new \UnexpectedValueException('Unknown dependency type: '.$type);
|
|
|
|
}
|
2011-09-16 19:14:06 +00:00
|
|
|
|
2011-04-17 22:14:44 +00:00
|
|
|
return $this->installers[$type];
|
|
|
|
}
|
|
|
|
|
2011-09-16 19:14:06 +00:00
|
|
|
public function setRepository($name, RepositoryInterface $repository = null)
|
2011-04-17 22:14:44 +00:00
|
|
|
{
|
2011-09-16 19:14:06 +00:00
|
|
|
if (null === $repository) {
|
2011-04-17 22:14:44 +00:00
|
|
|
unset($this->repositories[$name]);
|
2011-09-16 19:14:06 +00:00
|
|
|
|
|
|
|
return;
|
2011-04-17 22:14:44 +00:00
|
|
|
}
|
|
|
|
|
2011-09-16 19:14:06 +00:00
|
|
|
$this->repositories[$name] = $repository;
|
2011-04-17 22:14:44 +00:00
|
|
|
}
|
|
|
|
|
2011-09-16 19:14:06 +00:00
|
|
|
public function getRepository($name)
|
2011-04-17 22:14:44 +00:00
|
|
|
{
|
2011-09-16 19:14:06 +00:00
|
|
|
if (!isset($this->repositories[$name])) {
|
|
|
|
throw new \UnexpectedValueException('Unknown repository: '.$name);
|
2011-06-06 09:06:59 +00:00
|
|
|
}
|
2011-06-28 18:42:02 +00:00
|
|
|
|
2011-09-16 19:14:06 +00:00
|
|
|
return $this->repositories[$name];
|
|
|
|
}
|
2011-06-28 18:42:02 +00:00
|
|
|
|
2011-09-16 19:14:06 +00:00
|
|
|
public function getRepositories()
|
|
|
|
{
|
|
|
|
return $this->repositories;
|
2011-04-17 22:14:44 +00:00
|
|
|
}
|
2011-09-17 11:18:34 +00:00
|
|
|
}
|