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