‪TYPO3CMS  10.4
ClickEnlargeViewHelper.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
17 
22 use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
23 use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
24 use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
25 
41 class ‪ClickEnlargeViewHelper extends AbstractViewHelper
42 {
43  use CompileWithRenderStatic;
44 
48  protected ‪$escapeOutput = false;
49 
53  public function ‪initializeArguments()
54  {
55  $this->registerArgument('image', FileInterface::class, 'The original image file', true);
56  $this->registerArgument(
57  'configuration',
58  'mixed',
59  'String, \TYPO3\CMS\Core\Resource\File or \TYPO3\CMS\Core\Resource\FileReference with link configuration',
60  true
61  );
62  }
63 
70  public static function ‪renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
71  {
72  $image = $arguments['image'];
73  if ($image instanceof ‪FileInterface) {
75  }
76 
77  $objDataBackup = null;
78  if ($renderingContext->getVariableProvider()->exists('data')) {
79  $objDataBackup = ‪self::getContentObjectRenderer()->data;
80  ‪self::getContentObjectRenderer()->data = $renderingContext->getVariableProvider()->get('data');
81  }
82  $configuration = ‪self::getTypoScriptService()->‪convertPlainArrayToTypoScriptArray($arguments['configuration']);
83  $content = $renderChildrenClosure();
84  $configuration['enable'] = true;
85 
86  $result = ‪self::getContentObjectRenderer()->‪imageLinkWrap($content, $image, $configuration);
87  if ($objDataBackup) {
88  ‪self::getContentObjectRenderer()->data = $objDataBackup;
89  }
90  return $result;
91  }
92 
96  protected static function ‪getContentObjectRenderer()
97  {
98  return ‪$GLOBALS['TSFE']->cObj;
99  }
100 
104  protected static function ‪getTypoScriptService(): ‪TypoScriptService
105  {
106  return GeneralUtility::makeInstance(TypoScriptService::class);
107  }
108 }
‪TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer\setCurrentFile
‪setCurrentFile($fileObject)
Definition: ContentObjectRenderer.php:1559
‪TYPO3\CMS\Core\Resource\FileInterface
Definition: FileInterface.php:22
‪TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer\imageLinkWrap
‪string imageLinkWrap($string, $imageFile, $conf)
Definition: ContentObjectRenderer.php:1279
‪TYPO3\CMS\Core\TypoScript\TypoScriptService\convertPlainArrayToTypoScriptArray
‪array convertPlainArrayToTypoScriptArray(array $plainArray)
Definition: TypoScriptService.php:67
‪TYPO3\CMS\Core\TypoScript\TypoScriptService
Definition: TypoScriptService.php:25
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer
Definition: ContentObjectRenderer.php:97
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:46