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


PHP FileHelper::copyDirectory方法代碼示例

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


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

示例1: publish

 public function publish($path, $level = -1)
 {
     $assetPath = $this->generatePath($path);
     if (isset($this->_published[$path])) {
         return $this->_published[$path];
     }
     if (is_dir($this->getBasePath() . '/' . $assetPath) && ($this->fastCheck || FileHelper::md5Directory($this->getBasePath() . '/' . $assetPath) == FileHelper::md5Directory($path))) {
         return $this->getBaseUrl() . '/' . $assetPath;
     } else {
         if (!is_dir($this->getBasePath() . '/' . $assetPath)) {
             mkdir($this->getBasePath() . '/' . $assetPath, 0777, true);
         }
         FileHelper::copyDirectory($path, $this->getBasePath() . '/' . $assetPath, 0777, $level);
         $this->_published[$path] = $this->getBaseUrl() . '/' . $assetPath;
         return $this->_published[$path];
     }
 }
開發者ID:ruxon,項目名稱:framework,代碼行數:17,代碼來源:AssetManager.class.php

示例2: publishDirectory

 /**
  * Publishes a directory.
  * @param string $src the asset directory to be published
  * @param array $options the options to be applied when publishing a directory.
  * The following options are supported:
  *
  * - only: array, list of patterns that the file paths should match if they want to be copied.
  * - except: array, list of patterns that the files or directories should match if they want to be excluded from being copied.
  * - caseSensitive: boolean, whether patterns specified at "only" or "except" should be case sensitive. Defaults to true.
  * - beforeCopy: callback, a PHP callback that is called before copying each sub-directory or file.
  *   This overrides [[beforeCopy]] if set.
  * - afterCopy: callback, a PHP callback that is called after a sub-directory or file is successfully copied.
  *   This overrides [[afterCopy]] if set.
  * - forceCopy: boolean, whether the directory being published should be copied even if
  *   it is found in the target directory. This option is used only when publishing a directory.
  *   This overrides [[forceCopy]] if set.
  *
  * @return array the path directory and the URL that the asset is published as.
  * @throws InvalidParamException if the asset to be published does not exist.
  */
 protected function publishDirectory($src, $options)
 {
     \Yii::trace("src:{$src} option:" . print_r($options, true), __METHOD__);
     $dir = $this->hash($src);
     $dstDir = $this->basePath . DIRECTORY_SEPARATOR . $dir;
     \Yii::trace("dstDir:{$dstDir} ", __METHOD__);
     if ($this->linkAssets) {
         if (!is_dir($dstDir)) {
             symlink($src, $dstDir);
         }
     } elseif (!empty($options['forceCopy']) || $this->forceCopy && !isset($options['forceCopy']) || !is_dir($dstDir)) {
         $opts = array_merge($options, ['dirMode' => $this->dirMode, 'fileMode' => $this->fileMode]);
         if (!isset($opts['beforeCopy'])) {
             if ($this->beforeCopy !== null) {
                 $opts['beforeCopy'] = $this->beforeCopy;
             } else {
                 $opts['beforeCopy'] = function ($from, $to) {
                     return strncmp(basename($from), '.', 1) !== 0;
                 };
             }
         }
         if (!isset($opts['afterCopy']) && $this->afterCopy !== null) {
             $opts['afterCopy'] = $this->afterCopy;
         }
         FileHelper::copyDirectory($src, $dstDir, $opts);
     }
     return [$dstDir, $this->baseUrl . '/' . $dir];
 }
開發者ID:NetClearly,項目名稱:yii2-extensions,代碼行數:48,代碼來源:StaticAssetManager.php


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