本文整理汇总了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();
}
}
示例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);
}
}
}
示例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;
}
示例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);
}
}
}