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


PHP BaseFileHelper::findFiles方法代碼示例

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


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

示例1: getAllClasses

 public static function getAllClasses()
 {
     $result = [];
     foreach (self::getAllAliases() as $alias) {
         $path = \Yii::getAlias($alias);
         $files = is_dir($path) ? BaseFileHelper::findFiles($path) : [$path];
         foreach ($files as $filePath) {
             if (!preg_match('/.*\\/[A-Z]\\w+\\.php/', $filePath)) {
                 continue;
             }
             $className = str_replace([$path, '.php', '/', '@'], [$alias, '', '\\', ''], $filePath);
             $result[] = $className;
         }
     }
     return $result;
 }
開發者ID:bariew,項目名稱:yii2-tools,代碼行數:16,代碼來源:ClassHelper.php

示例2: getImageAdvert

 public static function getImageAdvert($data, $general = true, $original = false)
 {
     $image = [];
     $base = Url::base();
     if ($general) {
         $image[] = $base . '/uploads/adverts/' . $data['idadvert'] . '/general/small_' . $data['general_image'];
     } else {
         $path = \Yii::getAlias("@frontend/web/uploads/adverts/" . $data['idadvert']);
         $files = BaseFileHelper::findFiles($path);
         foreach ($files as $file) {
             if (strstr($file, 'small_') && !strstr($file, 'general')) {
                 $image[] = $base . 'uploads/adverts/' . $data['idadvert'] . '/' . basename($file);
             }
         }
     }
     return $image;
 }
開發者ID:scorp7mix,項目名稱:yii,代碼行數:17,代碼來源:Common.php

示例3: getAllClasses

 public static function getAllClasses()
 {
     if (self::$_allClasses !== null) {
         return self::$_allClasses;
     }
     $result = [];
     foreach (self::getAllAliases() as $alias) {
         $path = Yii::getAlias($alias);
         if (!file_exists($path) || is_file($path)) {
             continue;
         }
         $files = BaseFileHelper::findFiles($path, ['except' => ['/yii2-gii/', 'Yii.php']]);
         foreach ($files as $filePath) {
             if (!preg_match('/.*\\/[A-Z]\\w+\\.php/', $filePath)) {
                 continue;
             }
             $className = str_replace([$path, '.php', '/', '@'], [$alias, '', '\\', ''], $filePath);
             $result[] = $className;
         }
     }
     return self::$_allClasses = $result;
 }
開發者ID:EsoftsLimited,項目名稱:yii2-plugins-manager,代碼行數:22,代碼來源:Crawler.php

示例4: afterSave

 /**
  * После сохранения
  */
 public function afterSave()
 {
     $this->path = null;
     //Сохраняем файл
     foreach ($this->fields as $field) {
         $isWeb = $this->_webFile[$field];
         $file = null;
         if ($isWeb || ($file = UploadedFile::getInstance($this->owner, $field))) {
             //Директория для сохранения
             $path = $this->getPath($field);
             $files = BaseFileHelper::findFiles($path);
             foreach ($files as $cFile) {
                 @unlink($cFile);
             }
             $fileName = self::normalize($isWeb ? $this->_names[$field] : $file->name);
             $filePath = BaseFileHelper::normalizePath($path . '/' . $fileName);
             // d($filePath);
             if ($this->_webFile[$field]) {
                 $result = @copy($this->_webFile[$field], $filePath);
                 if (!$result) {
                     $fileName = '';
                 }
             } else {
                 $file->saveAs($path . '/' . $fileName);
                 chmod($filePath, 0666);
             }
             $this->owner->updateAttributes(array($field => $fileName));
         }
     }
     $this->setAttach();
 }
開發者ID:h11Nox,項目名稱:slug,代碼行數:34,代碼來源:FileBehavior.php

示例5: cleanup

 /**
  * Cleanup all files in the zip output path.
  */
 protected function cleanup()
 {
     $files = BaseFileHelper::findFiles($this->getBaseTempFolderPath(), ['filter' => function ($path) {
         return time() - filemtime($path) > 30 ? true : false;
     }, 'recursive' => true]);
     foreach ($files as $file) {
         unlink($file);
     }
 }
開發者ID:humhub,項目名稱:humhub-modules-cfiles,代碼行數:12,代碼來源:ZipController.php

示例6: findFiles

 /**
  * @inheritdoc
  * @staticvar boolean $searchProcess variable that indicates call method is recursively called or this is the first call.
  * Fixes logic of parent method. Some file systems may has file for which is_file === false and is_dir === false.
  * For example: windows file system has it where file has "alien" character set.
  * 
  * The method returns file paths which have local file system charset.
  * The `$dir` param must be in local file system charset too.
  */
 public static function findFiles($dir, $options = [])
 {
     static $searchProcess = false;
     if (!$searchProcess) {
         $searchProcess = true;
         try {
             $result = parent::findFiles($dir, $options);
         } catch (\Exception $ex) {
             $searchProcess = false;
             throw $ex;
         }
         $searchProcess = false;
         return $result;
     }
     if (!is_dir($dir)) {
         return [];
     }
     return parent::findFiles($dir, $options);
 }
開發者ID:alex-dwt,項目名稱:file,代碼行數:28,代碼來源:BaseFileSystemHelper.php


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