/** * 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; }
/** * {@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)); } }
public function getInstallationSource() { return $this->aliasOf->getInstallationSource(); }