2012-01-25 12:40:16 +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\Installer;
|
|
|
|
|
2012-04-17 22:59:42 +00:00
|
|
|
use Composer\Repository\InstalledRepositoryInterface;
|
2012-01-25 12:40:16 +00:00
|
|
|
use Composer\Package\PackageInterface;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Metapackage installation manager.
|
|
|
|
*
|
|
|
|
* @author Martin Hasoň <martin.hason@gmail.com>
|
|
|
|
*/
|
|
|
|
class MetapackageInstaller implements InstallerInterface
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
|
|
|
public function supports($packageType)
|
|
|
|
{
|
|
|
|
return $packageType === 'metapackage';
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
2012-04-17 22:59:42 +00:00
|
|
|
public function isInstalled(InstalledRepositoryInterface $repo, PackageInterface $package)
|
2012-01-25 12:40:16 +00:00
|
|
|
{
|
2012-04-14 13:45:25 +00:00
|
|
|
return $repo->hasPackage($package);
|
2012-01-25 12:40:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
2012-04-17 22:59:42 +00:00
|
|
|
public function install(InstalledRepositoryInterface $repo, PackageInterface $package)
|
2012-01-25 12:40:16 +00:00
|
|
|
{
|
2012-04-14 13:45:25 +00:00
|
|
|
$repo->addPackage(clone $package);
|
2012-01-25 12:40:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
2012-04-17 22:59:42 +00:00
|
|
|
public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target)
|
2012-01-25 12:40:16 +00:00
|
|
|
{
|
2012-04-14 13:45:25 +00:00
|
|
|
if (!$repo->hasPackage($initial)) {
|
2012-01-25 12:40:16 +00:00
|
|
|
throw new \InvalidArgumentException('Package is not installed: '.$initial);
|
|
|
|
}
|
|
|
|
|
2012-04-14 13:45:25 +00:00
|
|
|
$repo->removePackage($initial);
|
|
|
|
$repo->addPackage(clone $target);
|
2012-01-25 12:40:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
2012-04-17 22:59:42 +00:00
|
|
|
public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package)
|
2012-01-25 12:40:16 +00:00
|
|
|
{
|
2012-04-14 13:45:25 +00:00
|
|
|
if (!$repo->hasPackage($package)) {
|
2012-01-25 12:40:16 +00:00
|
|
|
// TODO throw exception again here, when update is fixed and we don't have to remove+install (see #125)
|
|
|
|
return;
|
|
|
|
throw new \InvalidArgumentException('Package is not installed: '.$package);
|
|
|
|
}
|
|
|
|
|
2012-04-14 13:45:25 +00:00
|
|
|
$repo->removePackage($package);
|
2012-01-25 12:40:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
|
|
|
public function getInstallPath(PackageInterface $package)
|
|
|
|
{
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
}
|