TYPO3 CMS  TYPO3_8-7
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 
21 
47 {
53  protected $escapeOutput = false;
54 
60  public function initializeArguments()
61  {
62  parent::initializeArguments();
63  $this->registerArgument('getVars', 'array', 'List of GET variables to store. By default the current id, module and all module arguments will be stored', false, []);
64  $this->registerArgument('setVars', 'array', 'List of SET[] variables to store. See DocumentTemplate::makeShortcutIcon(). Normally won\'t be used by Extbase modules', false, []);
65  }
66 
73  public function render()
74  {
75  return static::renderStatic(
76  $this->arguments,
77  $this->buildRenderChildrenClosure(),
78  $this->renderingContext
79  );
80  }
81 
88  public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
89  {
90  $getVars = $arguments['getVars'];
91  $setVars = $arguments['setVars'];
92 
93  $mayMakeShortcut = $GLOBALS['BE_USER']->mayMakeShortcut();
94 
95  if ($mayMakeShortcut) {
96  $doc = GeneralUtility::makeInstance(DocumentTemplate::class);
97  $currentRequest = $renderingContext->getControllerContext()->getRequest();
98  $extensionName = $currentRequest->getControllerExtensionName();
99  $moduleName = $currentRequest->getPluginName();
100  if (count($getVars) === 0) {
101  $modulePrefix = strtolower('tx_' . $extensionName . '_' . $moduleName);
102  $getVars = ['id', 'M', $modulePrefix];
103  }
104  $getList = implode(',', $getVars);
105  $setList = implode(',', $setVars);
106  return $doc->makeShortcutIcon($getList, $setList, $moduleName);
107  }
108  return '';
109  }
110 }
static makeInstance($className,... $constructorArguments)
static renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
if(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']