PearDownloader.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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\Downloader;
  12. use Composer\Package\PackageInterface;
  13. /**
  14. * Downloader for pear packages
  15. *
  16. * @author Jordi Boggiano <j.boggiano@seld.be>
  17. * @author Kirill chEbba Chebunin <iam@chebba.org>
  18. */
  19. class PearDownloader extends FileDownloader
  20. {
  21. /**
  22. * {@inheritDoc}
  23. */
  24. public function download(PackageInterface $package, $path)
  25. {
  26. parent::download($package, $path);
  27. $fileName = $this->getFileName($package, $path);
  28. if ($this->io->isVerbose()) {
  29. $this->io->write(' Installing PEAR package');
  30. }
  31. try {
  32. $pearExtractor = new PearPackageExtractor($fileName);
  33. $pearExtractor->extractTo($path);
  34. if ($this->io->isVerbose()) {
  35. $this->io->write(' Cleaning up');
  36. }
  37. unlink($fileName);
  38. } catch (\Exception $e) {
  39. // clean up
  40. $this->filesystem->removeDirectory($path);
  41. throw $e;
  42. }
  43. $this->io->write('');
  44. }
  45. }