2011-04-05 15:37:19 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This file is part of Composer.
|
|
|
|
*
|
|
|
|
* (c) Nils Adermann <naderman@naderman.de>
|
2011-04-16 12:42:35 +00:00
|
|
|
* Jordi Boggiano <j.boggiano@seld.be>
|
2011-04-05 15:37:19 +00:00
|
|
|
*
|
|
|
|
* For the full copyright and license information, please view the LICENSE
|
|
|
|
* file that was distributed with this source code.
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace Composer\DependencyResolver;
|
|
|
|
|
2011-06-08 09:32:41 +00:00
|
|
|
use Composer\Package\LinkConstraint\LinkConstraintInterface;
|
|
|
|
|
2011-04-05 15:37:19 +00:00
|
|
|
/**
|
|
|
|
* @author Nils Adermann <naderman@naderman.de>
|
|
|
|
*/
|
|
|
|
class Request
|
|
|
|
{
|
|
|
|
protected $jobs;
|
|
|
|
protected $pool;
|
|
|
|
|
|
|
|
public function __construct(Pool $pool)
|
|
|
|
{
|
|
|
|
$this->pool = $pool;
|
2011-10-30 22:53:44 +00:00
|
|
|
$this->jobs = array();
|
2011-04-05 15:37:19 +00:00
|
|
|
}
|
|
|
|
|
2011-05-22 21:54:48 +00:00
|
|
|
public function install($packageName, LinkConstraintInterface $constraint = null)
|
2011-04-05 15:37:19 +00:00
|
|
|
{
|
2011-09-17 14:18:49 +00:00
|
|
|
$this->addJob($packageName, 'install', $constraint);
|
2011-04-05 15:37:19 +00:00
|
|
|
}
|
|
|
|
|
2011-05-22 21:54:48 +00:00
|
|
|
public function update($packageName, LinkConstraintInterface $constraint = null)
|
2011-04-05 15:37:19 +00:00
|
|
|
{
|
2011-09-17 14:18:49 +00:00
|
|
|
$this->addJob($packageName, 'update', $constraint);
|
2011-04-05 15:37:19 +00:00
|
|
|
}
|
|
|
|
|
2011-05-22 21:54:48 +00:00
|
|
|
public function remove($packageName, LinkConstraintInterface $constraint = null)
|
2011-04-05 15:37:19 +00:00
|
|
|
{
|
2011-09-17 14:18:49 +00:00
|
|
|
$this->addJob($packageName, 'remove', $constraint);
|
2011-04-05 15:37:19 +00:00
|
|
|
}
|
|
|
|
|
2011-05-23 00:04:17 +00:00
|
|
|
protected function addJob($packageName, $cmd, LinkConstraintInterface $constraint = null)
|
2011-04-05 15:37:19 +00:00
|
|
|
{
|
2011-09-17 14:18:49 +00:00
|
|
|
$packageName = strtolower($packageName);
|
|
|
|
$packages = $this->pool->whatProvides($packageName, $constraint);
|
2011-04-05 15:37:19 +00:00
|
|
|
|
|
|
|
$this->jobs[] = array(
|
|
|
|
'packages' => $packages,
|
|
|
|
'cmd' => $cmd,
|
2011-09-17 14:18:49 +00:00
|
|
|
'packageName' => $packageName,
|
2011-04-05 15:37:19 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2012-02-19 15:59:04 +00:00
|
|
|
public function updateAll()
|
|
|
|
{
|
|
|
|
$this->jobs[] = array('cmd' => 'update-all', 'packages' => array());
|
|
|
|
}
|
|
|
|
|
2011-04-05 15:37:19 +00:00
|
|
|
public function getJobs()
|
|
|
|
{
|
|
|
|
return $this->jobs;
|
|
|
|
}
|
|
|
|
}
|