当前位置: 首页>>代码示例>>PHP>>正文


PHP File::getMimeType方法代码示例

本文整理汇总了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());
 }
开发者ID:khanhdeux,项目名称:typo3test,代码行数:15,代码来源:AbstractFileTest.php

示例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;
 }
开发者ID:,项目名称:,代码行数:31,代码来源:

示例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());
 }
开发者ID:rickymathew,项目名称:TYPO3.CMS,代码行数:16,代码来源:AbstractFileTest.php

示例4: getMimeType

 /**
  * Get the MIME type of this file
  *
  * @return string mime type
  */
 public function getMimeType()
 {
     return $this->originalFile->getMimeType();
 }
开发者ID:,项目名称:,代码行数:9,代码来源:


注:本文中的TYPO3\CMS\Core\Resource\File::getMimeType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。