예제 #1
0
 /**
  * Returns downloader for already installed package.
  *
  * @param   PackageInterface    $package    package instance
  *
  * @return  DownloaderInterface
  *
  * @throws  InvalidArgumentException        if package has no installation source specified
  * @throws  LogicException                  if specific downloader used to load package with
  *                                          wrong type
  */
 public function getDownloaderForInstalledPackage(PackageInterface $package)
 {
     $installationSource = $package->getInstallationSource();
     if ('dist' === $installationSource) {
         $downloader = $this->getDownloader($package->getDistType());
     } elseif ('source' === $installationSource) {
         $downloader = $this->getDownloader($package->getSourceType());
     } else {
         throw new \InvalidArgumentException('Package ' . $package . ' seems not been installed properly');
     }
     if ($installationSource !== $downloader->getInstallationSource()) {
         throw new \LogicException(sprintf('Downloader "%s" is a %s type downloader and can not be used to download %s', get_class($downloader), $downloader->getInstallationSource(), $installationSource));
     }
     return $downloader;
 }
예제 #2
0
 /**
  * {@inheritdoc}
  */
 public function getInstallationSource()
 {
     return $this->package->getInstallationSource();
 }
 /**
  * @param PackageInterface $package
  */
 public function setPackageInstallationSource(PackageInterface $package)
 {
     if (null == $package->getInstallationSource()) {
         $package->setInstallationSource($this->getPackageInstallationSource($package));
     }
 }
예제 #4
0
 public function getInstallationSource()
 {
     return $this->aliasOf->getInstallationSource();
 }