SvnDownloader.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. namespace Composer\Downloader;
  3. use Composer\Package\PackageInterface;
  4. /**
  5. * @author Ben Bieker <mail@ben-bieker.de>
  6. */
  7. class SvnDownloader implements DownloaderInterface
  8. {
  9. /**
  10. * {@inheritDoc}
  11. */
  12. public function getInstallationSource()
  13. {
  14. return 'source';
  15. }
  16. /**
  17. * {@inheritDoc}
  18. */
  19. public function download(PackageInterface $package, $path)
  20. {
  21. if(!$package->getSourceReference()) {
  22. throw new \InvalidArgumentException('The given package is missing reference information');
  23. }
  24. $url = escapeshellarg($package->getSourceUrl());
  25. $ref = escapeshellarg($package->getSourceReference());
  26. system(sprintf('svn co %s/%s %s', $url, $ref, $path));
  27. }
  28. /**
  29. * {@inheritDoc}
  30. */
  31. public function update(PackageInterface $initial, PackageInterface $target, $path)
  32. {
  33. if(!$target->getSourceReference()) {
  34. throw new \InvalidArgumentException('The given package is missing reference information');
  35. }
  36. $url = escapeshellarg($target->getSourceUrl());
  37. $ref = escapeshellarg($target->getSourceReference());
  38. system(sprintf('cd %s && svn switch %s/%s', $path, $url, $ref));
  39. }
  40. /**
  41. * {@inheritDoc}
  42. */
  43. public function remove(PackageInterface $package, $path)
  44. {
  45. $fs = new Util\Filesystem();
  46. $fs->remove($path);
  47. }
  48. }