Request.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. /*
  3. * This file is part of Composer.
  4. *
  5. * (c) Nils Adermann <naderman@naderman.de>
  6. * Jordi Boggiano <j.boggiano@seld.be>
  7. *
  8. * For the full copyright and license information, please view the LICENSE
  9. * file that was distributed with this source code.
  10. */
  11. namespace Composer\DependencyResolver;
  12. use Composer\Package\LinkConstraint\LinkConstraintInterface;
  13. /**
  14. * @author Nils Adermann <naderman@naderman.de>
  15. */
  16. class Request
  17. {
  18. protected $jobs;
  19. protected $pool;
  20. public function __construct(Pool $pool)
  21. {
  22. $this->pool = $pool;
  23. $this->jobs = array();
  24. }
  25. public function install($packageName, LinkConstraintInterface $constraint = null)
  26. {
  27. $this->addJob($packageName, 'install', $constraint);
  28. }
  29. public function update($packageName, LinkConstraintInterface $constraint = null)
  30. {
  31. $this->addJob($packageName, 'update', $constraint);
  32. }
  33. public function remove($packageName, LinkConstraintInterface $constraint = null)
  34. {
  35. $this->addJob($packageName, 'remove', $constraint);
  36. }
  37. protected function addJob($packageName, $cmd, LinkConstraintInterface $constraint = null)
  38. {
  39. $packageName = strtolower($packageName);
  40. $this->jobs[] = array(
  41. 'cmd' => $cmd,
  42. 'packageName' => $packageName,
  43. 'constraint' => $constraint,
  44. );
  45. }
  46. public function updateAll()
  47. {
  48. $this->jobs[] = array('cmd' => 'update-all');
  49. }
  50. public function getJobs()
  51. {
  52. return $this->jobs;
  53. }
  54. }