‪TYPO3CMS  9.5
ShortcutViewHelper.php
Go to the documentation of this file.
1 <?php
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
20 use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
21 
50 {
56  protected ‪$escapeOutput = false;
57 
63  public function ‪initializeArguments()
64  {
65  parent::initializeArguments();
66  $this->registerArgument('getVars', 'array', 'List of GET variables to store. By default the current id, module and all module arguments will be stored', false, []);
67  $this->registerArgument('setVars', 'array', 'List of SET[] variables to store. See DocumentTemplate::makeShortcutIcon(). Normally won\'t be used by Extbase modules', false, []);
68  }
69 
76  public function ‪render()
77  {
78  return static::renderStatic(
79  $this->arguments,
80  $this->buildRenderChildrenClosure(),
81  $this->renderingContext
82  );
83  }
84 
91  public static function ‪renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
92  {
93  $getVars = $arguments['getVars'];
94  $setVars = $arguments['setVars'];
95 
96  $mayMakeShortcut = ‪$GLOBALS['BE_USER']->mayMakeShortcut();
97 
98  if ($mayMakeShortcut) {
99  $doc = GeneralUtility::makeInstance(DocumentTemplate::class);
100  $currentRequest = $renderingContext->getControllerContext()->getRequest();
101  $extensionName = $currentRequest->getControllerExtensionName();
102  $moduleName = $currentRequest->getPluginName();
103  if (count($getVars) === 0) {
104  $modulePrefix = strtolower('tx_' . $extensionName . '_' . $moduleName);
105  $getVars = ['id', 'route', $modulePrefix];
106  }
107  $getList = implode(',', $getVars);
108  $setList = implode(',', $setVars);
109  return $doc->makeShortcutIcon($getList, $setList, $moduleName);
110  }
111  return '';
112  }
113 }
‪TYPO3\CMS\Fluid\ViewHelpers\Be\Buttons\ShortcutViewHelper\render
‪string render()
Definition: ShortcutViewHelper.php:75
‪TYPO3\CMS\Fluid\ViewHelpers\Be\Buttons\ShortcutViewHelper\$escapeOutput
‪bool $escapeOutput
Definition: ShortcutViewHelper.php:55
‪TYPO3\CMS\Fluid\ViewHelpers\Be\AbstractBackendViewHelper
Definition: AbstractBackendViewHelper.php:27
‪TYPO3\CMS\Backend\Template\DocumentTemplate
Definition: DocumentTemplate.php:48
‪TYPO3\CMS\Fluid\ViewHelpers\Be\Buttons\ShortcutViewHelper\initializeArguments
‪initializeArguments()
Definition: ShortcutViewHelper.php:62
‪TYPO3\CMS\Fluid\ViewHelpers\Be\Buttons\ShortcutViewHelper
Definition: ShortcutViewHelper.php:50
‪$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:90
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:45
‪TYPO3\CMS\Fluid\ViewHelpers\Be\Buttons
Definition: CshViewHelper.php:2