本文整理汇总了PHP中TYPO3\CMS\Core\Resource\File::getMimeType方法的典型用法代码示例。如果您正苦于以下问题:PHP File::getMimeType方法的具体用法?PHP File::getMimeType怎么用?PHP File::getMimeType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TYPO3\CMS\Core\Resource\File
的用法示例。
在下文中一共展示了File::getMimeType方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: storageIsNotAskedForMimeTypeForPersistedRecord
/**
* This test accounts for an inconsistency in the Storage–Driver interface of FAL: The driver returns the MIME
* type in a field "mimetype", while the file object and the database table use mime_type.
* The test is placed in the test case for AbstractFile because the broken functionality resides there, though
* it is only triggered when constructing a File instance with an index record.
*
* @test
*/
public function storageIsNotAskedForMimeTypeForPersistedRecord()
{
$mockedStorage = $this->getMockBuilder('TYPO3\\CMS\\Core\\Resource\\ResourceStorage')->disableOriginalConstructor()->getMock();
$mockedStorage->expects($this->never())->method('getFileInfoByIdentifier')->with('/foo', 'mimetype');
$subject = new File(array('identifier' => '/foo', 'mime_type' => 'my/mime-type'), $mockedStorage);
$this->assertEquals('my/mime-type', $subject->getMimeType());
}
示例2: renderFileInformationContent
/**
* Renders a HTML Block with file information
*
* @param File $file
* @return string
*/
protected function renderFileInformationContent(File $file = null)
{
/** @var LanguageService $lang */
$lang = $GLOBALS['LANG'];
if ($file !== null) {
$processedFile = $file->process(ProcessedFile::CONTEXT_IMAGEPREVIEW, ['width' => 150, 'height' => 150]);
$previewImage = $processedFile->getPublicUrl(true);
$content = '';
if ($file->isMissing()) {
$content .= '<span class="label label-danger label-space-right">' . htmlspecialchars($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:warning.file_missing')) . '</span>';
}
if ($previewImage) {
$content .= '<img src="' . htmlspecialchars($previewImage) . '" ' . 'width="' . $processedFile->getProperty('width') . '" ' . 'height="' . $processedFile->getProperty('height') . '" ' . 'alt="" class="t3-tceforms-sysfile-imagepreview" />';
}
$content .= '<strong>' . htmlspecialchars($file->getName()) . '</strong>';
$content .= ' (' . htmlspecialchars(GeneralUtility::formatSize($file->getSize())) . 'bytes)<br />';
$content .= BackendUtility::getProcessedValue('sys_file', 'type', $file->getType()) . ' (' . $file->getMimeType() . ')<br />';
$content .= htmlspecialchars($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_misc.xlf:fileMetaDataLocation')) . ': ';
$content .= htmlspecialchars($file->getStorage()->getName()) . ' - ' . htmlspecialchars($file->getIdentifier()) . '<br />';
$content .= '<br />';
} else {
$content = '<h2>' . htmlspecialchars($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_misc.xlf:fileMetaErrorInvalidRecord')) . '</h2>';
}
return $content;
}
示例3: storageIsNotAskedForMimeTypeForPersistedRecord
/**
* This test accounts for an inconsistency in the Storage–Driver interface of FAL: The driver returns the MIME
* type in a field "mimetype", while the file object and the database table use mime_type.
* The test is placed in the test case for AbstractFile because the broken functionality resides there, though
* it is only triggered when constructing a File instance with an index record.
*
* @test
*/
public function storageIsNotAskedForMimeTypeForPersistedRecord()
{
/** @var ResourceStorage|\PHPUnit_Framework_MockObject_MockObject $mockedStorage */
$mockedStorage = $this->getMockBuilder(ResourceStorage::class)->disableOriginalConstructor()->getMock();
$mockedStorage->expects($this->never())->method('getFileInfoByIdentifier')->with('/foo', 'mimetype');
$subject = new File(array('identifier' => '/foo', 'mime_type' => 'my/mime-type'), $mockedStorage);
$this->assertEquals('my/mime-type', $subject->getMimeType());
}
示例4: getMimeType
/**
* Get the MIME type of this file
*
* @return string mime type
*/
public function getMimeType()
{
return $this->originalFile->getMimeType();
}