本文整理汇总了PHP中TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::setCurrentFile方法的典型用法代码示例。如果您正苦于以下问题:PHP ContentObjectRenderer::setCurrentFile方法的具体用法?PHP ContentObjectRenderer::setCurrentFile怎么用?PHP ContentObjectRenderer::setCurrentFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer
的用法示例。
在下文中一共展示了ContentObjectRenderer::setCurrentFile方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getDataWithTypeFileReturnsUidOfFileObject
/**
* Basic check if getData gets the uid of a file object
*
* @test
*/
public function getDataWithTypeFileReturnsUidOfFileObject() {
$uid = $this->getUniqueId();
$file = $this->getMock(\TYPO3\CMS\Core\Resource\File::class, array(), array(), '', FALSE);
$file->expects($this->once())->method('getUid')->will($this->returnValue($uid));
$this->subject->setCurrentFile($file);
$this->assertEquals($uid, $this->subject->getData('file:current:uid'));
}
示例2: renderLinktypeFile
/**
* Render link of type file
*
* @param array $lConf
* @return array
*/
private function renderLinktypeFile($lConf)
{
$viewAssign = array();
// Get file
$fileRepository = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Resource\\FileRepository');
$fileObjects = $fileRepository->findByRelation('tt_content', 'mfp_image', $this->data['uid']);
/** @var \TYPO3\CMS\Core\Resource\File $file */
$file = $fileObjects[0];
if (!empty($file)) {
// Configure the image
$this->cObj->setCurrentFile($file);
$imageConf = $GLOBALS['TSFE']->tmpl->setup['lib.']['tx_jhmagnificpopup_pi1.']['image.'];
$imageConf['file.']['treatIdAsReference'] = 1;
$imageConf['file'] = $file;
if (!empty($this->settings['mfpOption']['file_width'])) {
$imageConf["file."]["maxW"] = $this->settings['mfpOption']['file_width'];
}
if (!empty($this->settings['mfpOption']['file_height'])) {
$imageConf["file."]["maxH"] = $this->settings['mfpOption']['file_height'];
}
// Render image
$theImgCode = $this->cObj->IMAGE($imageConf);
// Get image orientation
switch ($this->settings['mfpOption']['file_orient']) {
case 1:
$viewAssign['imageorient'] = 'right';
break;
case 2:
$viewAssign['imageorient'] = 'left';
break;
case 0:
default:
$viewAssign['imageorient'] = 'center';
}
// Get image description/caption
$viewAssign['imagecaption'] = $file->getProperty('description');
// Render typolink
$viewAssign['tsLink'] = $this->cObj->typolink($theImgCode, $lConf);
} else {
$this->addFlashMessage('Please select an image', 'No image', AbstractMessage::WARNING);
}
return $viewAssign;
}