当前位置: 首页>>代码示例>>PHP>>正文


PHP IOHelper::getFiles方法代码示例

本文整理汇总了PHP中IOHelper::getFiles方法的典型用法代码示例。如果您正苦于以下问题:PHP IOHelper::getFiles方法的具体用法?PHP IOHelper::getFiles怎么用?PHP IOHelper::getFiles使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IOHelper的用法示例。


在下文中一共展示了IOHelper::getFiles方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: actionDownloadFile

 /**
  * Downloads a file and cleans up old temporary assets
  */
 public function actionDownloadFile()
 {
     // Clean up temp assets files that are more than a day old
     $fileResults = array();
     $files = IOHelper::getFiles(craft()->path->getTempPath(), true);
     foreach ($files as $file) {
         $lastModifiedTime = IOHelper::getLastTimeModified($file, true);
         if (substr(IOHelper::getFileName($file, false, true), 0, 6) === "assets" && DateTimeHelper::currentTimeStamp() - $lastModifiedTime->getTimestamp() >= 86400) {
             IOHelper::deleteFile($file);
         }
     }
     // Sort out the file we want to download
     $id = craft()->request->getParam('id');
     $criteria = craft()->elements->getCriteria(ElementType::Asset);
     $criteria->id = $id;
     $asset = $criteria->first();
     if ($asset) {
         // Get a local copy of the file
         $sourceType = craft()->assetSources->getSourceTypeById($asset->sourceId);
         $localCopy = $sourceType->getLocalCopy($asset);
         // Send it to the browser
         craft()->request->sendFile($asset->filename, IOHelper::getFileContents($localCopy), array('forceDownload' => true));
         craft()->end();
     }
 }
开发者ID:supercool,项目名称:Tools,代码行数:28,代码来源:SupercoolToolsController.php

示例2: deleteExpiredCache

 /**
  * Based on the cache's hashed base, attempts to delete any older versions of same name.
  */
 public function deleteExpiredCache()
 {
     MinimeePlugin::log(Craft::t('Minimee is attempting to delete expired caches.'));
     $files = IOHelper::getFiles($this->settings->cachePath);
     foreach ($files as $file) {
         // skip self
         if ($file === $this->makePathToCacheFilename()) {
             continue;
         }
         if (strpos($file, $this->makePathToHashOfCacheBase()) === 0) {
             MinimeePlugin::log(Craft::t('Minimee is attempting to delete file: ') . $file);
             // suppress errors by passing true as second parameter
             IOHelper::deleteFile($file, true);
         }
     }
 }
开发者ID:speder,项目名称:craft.minimee,代码行数:19,代码来源:MinimeeService.php

示例3: loadConfigsFromDirectory

 /**
  * Load Configs From Directory
  *
  * @param string $directory Directory
  *
  * @return array Configs
  */
 private function loadConfigsFromDirectory($directory)
 {
     $configs = [];
     if (!($files = IOHelper::getFiles($directory))) {
         return $configs;
     }
     foreach ($files as $file) {
         $fileName = IOHelper::getFileName($file, false);
         $configs[$fileName] = (require $file);
     }
     return $configs;
 }
开发者ID:airtype,项目名称:craft-httpmessages,代码行数:19,代码来源:HttpMessages_ConfigService.php

示例4: deleteExportFilesForForm

 /**
  * Delete export files for a form.
  *
  * @param AmForms_FormModel $form
  *
  * @return bool
  */
 public function deleteExportFilesForForm(AmForms_FormModel $form)
 {
     $files = IOHelper::getFiles($this->_getExportPath());
     if (!$files || !count($files)) {
         return false;
     }
     foreach ($files as $file) {
         if (strpos($file, $form->handle) !== false) {
             IOHelper::deleteFile($file);
         }
     }
 }
开发者ID:webremote,项目名称:amforms,代码行数:19,代码来源:AmForms_ExportsService.php


注:本文中的IOHelper::getFiles方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。