Example #1
0
 /**
  * @param  IO\IOInterface             $io
  * @param  Config                     $config
  * @param  EventDispatcher            $eventDispatcher
  * @return Downloader\DownloadManager
  */
 public function createDownloadManager(IOInterface $io, Config $config, EventDispatcher $eventDispatcher = null, RemoteFilesystem $rfs = null)
 {
     $cache = null;
     if ($config->get('cache-files-ttl') > 0) {
         $cache = new Cache($io, $config->get('cache-files-dir'), 'a-z0-9_./');
     }
     $dm = new Downloader\DownloadManager($io);
     switch ($preferred = $config->get('preferred-install')) {
         case 'dist':
             $dm->setPreferDist(true);
             break;
         case 'source':
             $dm->setPreferSource(true);
             break;
         case 'auto':
         default:
             // noop
             break;
     }
     if (is_array($preferred)) {
         $dm->setPreferences($preferred);
     }
     $executor = new ProcessExecutor($io);
     $fs = new Filesystem($executor);
     $dm->setDownloader('git', new Downloader\GitDownloader($io, $config, $executor, $fs));
     $dm->setDownloader('svn', new Downloader\SvnDownloader($io, $config, $executor, $fs));
     $dm->setDownloader('fossil', new Downloader\FossilDownloader($io, $config, $executor, $fs));
     $dm->setDownloader('hg', new Downloader\HgDownloader($io, $config, $executor, $fs));
     $dm->setDownloader('perforce', new Downloader\PerforceDownloader($io, $config));
     $dm->setDownloader('zip', new Downloader\ZipDownloader($io, $config, $eventDispatcher, $cache, $executor, $rfs));
     $dm->setDownloader('rar', new Downloader\RarDownloader($io, $config, $eventDispatcher, $cache, $executor, $rfs));
     $dm->setDownloader('tar', new Downloader\TarDownloader($io, $config, $eventDispatcher, $cache, $rfs));
     $dm->setDownloader('gzip', new Downloader\GzipDownloader($io, $config, $eventDispatcher, $cache, $executor, $rfs));
     $dm->setDownloader('xz', new Downloader\XzDownloader($io, $config, $eventDispatcher, $cache, $executor, $rfs));
     $dm->setDownloader('phar', new Downloader\PharDownloader($io, $config, $eventDispatcher, $cache, $rfs));
     $dm->setDownloader('file', new Downloader\FileDownloader($io, $config, $eventDispatcher, $cache, $rfs));
     $dm->setDownloader('path', new Downloader\PathDownloader($io, $config, $eventDispatcher, $cache, $rfs));
     return $dm;
 }