‪TYPO3CMS  10.4
ShortcutViewHelper.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 
21 use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
22 
51 {
57  protected ‪$escapeOutput = false;
58 
64  public function ‪initializeArguments()
65  {
66  parent::initializeArguments();
67  $this->registerArgument('getVars', 'array', 'List of GET variables to store. By default the current id, module and all module arguments will be stored', false, []);
68  $this->registerArgument('setVars', 'array', 'List of SET[] variables to store. See ModuleTemplate::makeShortcutIcon(). Normally won\'t be used by Extbase modules', false, []);
69  }
70 
77  public function ‪render()
78  {
79  return static::renderStatic(
80  $this->arguments,
81  $this->buildRenderChildrenClosure(),
82  $this->renderingContext
83  );
84  }
85 
92  public static function ‪renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
93  {
94  $getVars = $arguments['getVars'];
95  $setVars = $arguments['setVars'];
96 
97  $mayMakeShortcut = ‪$GLOBALS['BE_USER']->mayMakeShortcut();
98 
99  if ($mayMakeShortcut) {
100  $moduleTemplate = GeneralUtility::makeInstance(ModuleTemplate::class);
101  $currentRequest = $renderingContext->getControllerContext()->getRequest();
102  $extensionName = $currentRequest->getControllerExtensionName();
103  $moduleName = $currentRequest->getPluginName();
104  if (count($getVars) === 0) {
105  $modulePrefix = strtolower('tx_' . $extensionName . '_' . $moduleName);
106  $getVars = ['id', 'route', $modulePrefix];
107  }
108  $getList = implode(',', $getVars);
109  $setList = implode(',', $setVars);
110  return $moduleTemplate->makeShortcutIcon($getList, $setList, $moduleName);
111  }
112  return '';
113  }
114 }
‪TYPO3\CMS\Fluid\ViewHelpers\Be\Buttons\ShortcutViewHelper\render
‪string render()
Definition: ShortcutViewHelper.php:76
‪TYPO3\CMS\Fluid\ViewHelpers\Be\Buttons\ShortcutViewHelper\$escapeOutput
‪bool $escapeOutput
Definition: ShortcutViewHelper.php:56
‪TYPO3\CMS\Fluid\ViewHelpers\Be\AbstractBackendViewHelper
Definition: AbstractBackendViewHelper.php:28
‪TYPO3\CMS\Backend\Template\ModuleTemplate
Definition: ModuleTemplate.php:43
‪TYPO3\CMS\Fluid\ViewHelpers\Be\Buttons\ShortcutViewHelper\initializeArguments
‪initializeArguments()
Definition: ShortcutViewHelper.php:63
‪TYPO3\CMS\Fluid\ViewHelpers\Be\Buttons\ShortcutViewHelper
Definition: ShortcutViewHelper.php:51
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Fluid\ViewHelpers\Be\Buttons\ShortcutViewHelper\renderStatic
‪static string renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
Definition: ShortcutViewHelper.php:91
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:46
‪TYPO3\CMS\Fluid\ViewHelpers\Be\Buttons
Definition: CshViewHelper.php:16