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