本文整理匯總了PHP中Composer\Package\PackageInterface::setInstallationSource方法的典型用法代碼示例。如果您正苦於以下問題:PHP PackageInterface::setInstallationSource方法的具體用法?PHP PackageInterface::setInstallationSource怎麽用?PHP PackageInterface::setInstallationSource使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Composer\Package\PackageInterface
的用法示例。
在下文中一共展示了PackageInterface::setInstallationSource方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: download
public function download(PackageInterface $package, $targetDir, $preferSource = null)
{
$preferSource = null !== $preferSource ? $preferSource : $this->preferSource;
$sourceType = $package->getSourceType();
$distType = $package->getDistType();
if ((!$package->isDev() || $this->preferDist || !$sourceType) && !($preferSource && $sourceType) && $distType) {
$package->setInstallationSource('dist');
} elseif ($sourceType) {
$package->setInstallationSource('source');
} else {
throw new \InvalidArgumentException('Package ' . $package . ' must have a source or dist specified');
}
$this->filesystem->ensureDirectoryExists($targetDir);
$downloader = $this->getDownloaderForInstalledPackage($package);
$downloader->download($package, $targetDir);
}
示例2: setInstallationSource
/**
* {@inheritdoc}
*/
public function setInstallationSource($type)
{
$this->package->setInstallationSource($type);
}
示例3: setPackageInstallationSource
/**
* @param PackageInterface $package
*/
public function setPackageInstallationSource(PackageInterface $package)
{
if (null == $package->getInstallationSource()) {
$package->setInstallationSource($this->getPackageInstallationSource($package));
}
}
示例4: setInstallationSource
public function setInstallationSource($type)
{
$this->aliasOf->setInstallationSource($type);
}
示例5: download
/**
* Downloads package into target dir.
*
* @param PackageInterface $package package instance
* @param string $targetDir target dir
* @param bool $preferSource prefer installation from source
*
* @throws \InvalidArgumentException if package have no urls to download from
* @throws \RuntimeException
*/
public function download(PackageInterface $package, $targetDir, $preferSource = null)
{
$preferSource = null !== $preferSource ? $preferSource : $this->preferSource;
$sourceType = $package->getSourceType();
$distType = $package->getDistType();
$sources = array();
if ($sourceType) {
$sources[] = 'source';
}
if ($distType) {
$sources[] = 'dist';
}
if (empty($sources)) {
throw new \InvalidArgumentException('Package ' . $package . ' must have a source or dist specified');
}
if ((!$package->isDev() || $this->preferDist) && !$preferSource) {
$sources = array_reverse($sources);
}
$this->filesystem->ensureDirectoryExists($targetDir);
foreach ($sources as $i => $source) {
if (isset($e)) {
$this->io->writeError(' <warning>Now trying to download from ' . $source . '</warning>');
}
$package->setInstallationSource($source);
try {
$downloader = $this->getDownloaderForInstalledPackage($package);
if ($downloader) {
$downloader->download($package, $targetDir);
}
break;
} catch (\RuntimeException $e) {
if ($i === count($sources) - 1) {
throw $e;
}
$this->io->writeError(' <warning>Failed to download ' . $package->getPrettyName() . ' from ' . $source . ': ' . $e->getMessage() . '</warning>');
}
}
}
示例6: update
/**
* Updates package from initial to target version.
*
* @param PackageInterface $initial initial package version
* @param PackageInterface $target target package version
* @param string $targetDir target dir
*
* @throws InvalidArgumentException if initial package is not installed
*/
public function update(PackageInterface $initial, PackageInterface $target, $targetDir)
{
$downloader = $this->getDownloaderForInstalledPackage($initial);
$installationSource = $initial->getInstallationSource();
if ('dist' === $installationSource) {
$initialType = $initial->getDistType();
$targetType = $target->getDistType();
} else {
$initialType = $initial->getSourceType();
$targetType = $target->getSourceType();
}
if ($initialType === $targetType) {
$target->setInstallationSource($installationSource);
$downloader->update($initial, $target, $targetDir);
} else {
$downloader->remove($initial, $targetDir);
$this->download($target, $targetDir, 'source' === $installationSource);
}
}