本文整理匯總了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;
}
示例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;
}