當前位置: 首頁>>代碼示例>>PHP>>正文


PHP PackageInterface::setInstallationSource方法代碼示例

本文整理匯總了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);
 }
開發者ID:itillawarra,項目名稱:cmfive,代碼行數:16,代碼來源:DownloadManager.php

示例2: setInstallationSource

 /**
  * {@inheritdoc}
  */
 public function setInstallationSource($type)
 {
     $this->package->setInstallationSource($type);
 }
開發者ID:tenside,項目名稱:core,代碼行數:7,代碼來源:VersionedPackage.php

示例3: setPackageInstallationSource

 /**
  * @param PackageInterface $package
  */
 public function setPackageInstallationSource(PackageInterface $package)
 {
     if (null == $package->getInstallationSource()) {
         $package->setInstallationSource($this->getPackageInstallationSource($package));
     }
 }
開發者ID:letudiant,項目名稱:composer-shared-package-plugin,代碼行數:9,代碼來源:SharedPackageDataManager.php

示例4: setInstallationSource

 public function setInstallationSource($type)
 {
     $this->aliasOf->setInstallationSource($type);
 }
開發者ID:neon64,項目名稱:composer,代碼行數:4,代碼來源:AliasPackage.php

示例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>');
         }
     }
 }
開發者ID:alancleaver,項目名稱:composer,代碼行數:48,代碼來源:DownloadManager.php

示例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);
     }
 }
開發者ID:natxet,項目名稱:composer,代碼行數:28,代碼來源:DownloadManager.php


注:本文中的Composer\Package\PackageInterface::setInstallationSource方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。