‪TYPO3CMS  ‪main
ClickEnlargeViewHelper.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
24 use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
25 use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
26 use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
27 
43 final class ‪ClickEnlargeViewHelper extends AbstractViewHelper
44 {
45  use CompileWithRenderStatic;
46 
50  protected ‪$escapeOutput = false;
51 
52  public function ‪initializeArguments(): void
53  {
54  $this->registerArgument('image', FileInterface::class, 'The original image file', true);
55  $this->registerArgument(
56  'configuration',
57  'array',
58  'TypoScript properties for the "imageLinkWrap" function',
59  true
60  );
61  }
62 
63  public static function ‪renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext): string
64  {
66  $image = $arguments['image'];
67  ‪self::getContentObjectRenderer()->setCurrentFile($image);
68 
69  $objDataBackup = null;
70  if ($renderingContext->getVariableProvider()->exists('data')) {
71  $objDataBackup = ‪self::getContentObjectRenderer()->data;
72  ‪self::getContentObjectRenderer()->data = $renderingContext->getVariableProvider()->get('data');
73  }
74  $configuration = ‪self::getTypoScriptService()->convertPlainArrayToTypoScriptArray($arguments['configuration']);
75  $content = $renderChildrenClosure();
76  $configuration['enable'] = true;
77 
78  $result = ‪self::getContentObjectRenderer()->imageLinkWrap((string)$content, $image, $configuration);
79  if ($objDataBackup) {
80  ‪self::getContentObjectRenderer()->data = $objDataBackup;
81  }
82  return $result;
83  }
84 
85  protected static function ‪getContentObjectRenderer(): ‪ContentObjectRenderer
86  {
87  return ‪$GLOBALS['TSFE']->cObj;
88  }
89 
90  protected static function ‪getTypoScriptService(): ‪TypoScriptService
91  {
92  return GeneralUtility::makeInstance(TypoScriptService::class);
93  }
94 }
‪TYPO3\CMS\Core\Resource\FileInterface
Definition: FileInterface.php:26
‪TYPO3\CMS\Core\TypoScript\TypoScriptService
Definition: TypoScriptService.php:27
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:25
‪TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer
Definition: ContentObjectRenderer.php:102
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:52