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


PHP PackageInterface::getTransportOptions方法代碼示例

本文整理匯總了PHP中Composer\Package\PackageInterface::getTransportOptions方法的典型用法代碼示例。如果您正苦於以下問題:PHP PackageInterface::getTransportOptions方法的具體用法?PHP PackageInterface::getTransportOptions怎麽用?PHP PackageInterface::getTransportOptions使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Composer\Package\PackageInterface的用法示例。


在下文中一共展示了PackageInterface::getTransportOptions方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: download

 /**
  * {@inheritdoc}
  */
 public function download(PackageInterface $package, $path)
 {
     $url = $package->getDistUrl();
     $realUrl = realpath($url);
     if (false === $realUrl || !file_exists($realUrl) || !is_dir($realUrl)) {
         throw new \RuntimeException(sprintf('Source path "%s" is not found for package %s', $url, $package->getName()));
     }
     if (strpos(realpath($path) . DIRECTORY_SEPARATOR, $realUrl . DIRECTORY_SEPARATOR) === 0) {
         throw new \RuntimeException(sprintf('Package %s cannot install to "%s" inside its source at "%s"', $package->getName(), realpath($path), $realUrl));
     }
     // Get the transport options with default values
     $transportOptions = $package->getTransportOptions() + array('symlink' => null);
     // When symlink transport option is null, both symlink and mirror are allowed
     $currentStrategy = self::STRATEGY_SYMLINK;
     $allowedStrategies = array(self::STRATEGY_SYMLINK, self::STRATEGY_MIRROR);
     if (true === $transportOptions['symlink']) {
         $currentStrategy = self::STRATEGY_SYMLINK;
         $allowedStrategies = array(self::STRATEGY_SYMLINK);
     } elseif (false === $transportOptions['symlink']) {
         $currentStrategy = self::STRATEGY_MIRROR;
         $allowedStrategies = array(self::STRATEGY_MIRROR);
     }
     $fileSystem = new Filesystem();
     $this->filesystem->removeDirectory($path);
     $this->io->writeError(sprintf('  - Installing <info>%s</info> (<comment>%s</comment>)', $package->getName(), $package->getFullPrettyVersion()));
     if (self::STRATEGY_SYMLINK == $currentStrategy) {
         try {
             if (Platform::isWindows()) {
                 // Implement symlinks as NTFS junctions on Windows
                 $this->filesystem->junction($realUrl, $path);
                 $this->io->writeError(sprintf('    Junctioned from %s', $url));
             } else {
                 $absolutePath = $path;
                 if (!$this->filesystem->isAbsolutePath($absolutePath)) {
                     $absolutePath = getcwd() . DIRECTORY_SEPARATOR . $path;
                 }
                 $shortestPath = $this->filesystem->findShortestPath($absolutePath, $realUrl);
                 $path = rtrim($path, "/");
                 $fileSystem->symlink($shortestPath, $path);
                 $this->io->writeError(sprintf('    Symlinked from %s', $url));
             }
         } catch (IOException $e) {
             if (in_array(self::STRATEGY_MIRROR, $allowedStrategies)) {
                 $this->io->writeError('    <error>Symlink failed, fallback to use mirroring!</error>');
                 $currentStrategy = self::STRATEGY_MIRROR;
             } else {
                 throw new \RuntimeException(sprintf('Symlink from "%s" to "%s" failed!', $realUrl, $path));
             }
         }
     }
     // Fallback if symlink failed or if symlink is not allowed for the package
     if (self::STRATEGY_MIRROR == $currentStrategy) {
         $fileSystem->mirror($realUrl, $path);
         $this->io->writeError(sprintf('    Mirrored from %s', $url));
     }
     $this->io->writeError('');
 }
開發者ID:dazzle-libraries,項目名稱:composer,代碼行數:60,代碼來源:PathDownloader.php

示例2: getTransportOptions

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

示例3: getTransportOptions

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


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