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


PHP File::exists方法代碼示例

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


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

示例1: create

 /**
  * Render a thumbnail of a media
  *
  * @throws MissingTcaConfigurationException
  * @return string
  */
 public function create()
 {
     if (empty($this->file)) {
         throw new MissingTcaConfigurationException('Missing File object. Forgotten to set a file?', 1355933144);
     }
     // Default class name
     $className = 'Fab\\Media\\Thumbnail\\FallBackThumbnailProcessor';
     if (File::FILETYPE_IMAGE == $this->file->getType()) {
         $className = 'Fab\\Media\\Thumbnail\\ImageThumbnailProcessor';
     } elseif (File::FILETYPE_AUDIO == $this->file->getType()) {
         $className = 'Fab\\Media\\Thumbnail\\AudioThumbnailProcessor';
     } elseif (File::FILETYPE_VIDEO == $this->file->getType()) {
         $className = 'Fab\\Media\\Thumbnail\\VideoThumbnailProcessor';
     } elseif (File::FILETYPE_APPLICATION == $this->file->getType() || File::FILETYPE_TEXT == $this->file->getType()) {
         $className = 'Fab\\Media\\Thumbnail\\ApplicationThumbnailProcessor';
     }
     /** @var $processorInstance \Fab\Media\Thumbnail\ThumbnailProcessorInterface */
     $processorInstance = GeneralUtility::makeInstance($className);
     $thumbnail = '';
     if ($this->file->exists()) {
         $thumbnail = $processorInstance->setThumbnailService($this)->create();
     } else {
         $logger = Logger::getInstance($this);
         $logger->warning(sprintf('Resource not found for File uid "%s" at %s', $this->file->getUid(), $this->file->getIdentifier()));
     }
     return $thumbnail;
 }
開發者ID:visol,項目名稱:media,代碼行數:33,代碼來源:ThumbnailService.php

示例2: downloadAction

 /**
  * Force download of the file.
  *
  * @param File $file
  * @param bool $forceDownload
  * @return bool|string
  */
 public function downloadAction(File $file, $forceDownload = FALSE)
 {
     if ($file->exists() && $file->getStorage()->isWithinFileMountBoundaries($file->getParentFolder())) {
         // Emit signal before downloading the file.
         $this->emitBeforeDownloadSignal($file);
         // Read the file and dump it with the flag "forceDownload" set to TRUE or FALSE.
         $file->getStorage()->dumpFileContents($file, $forceDownload);
         $result = TRUE;
     } else {
         $result = 'Access denied!';
     }
     return $result;
 }
開發者ID:visol,項目名稱:media,代碼行數:20,代碼來源:AssetController.php


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