‪TYPO3CMS  9.5
ShortcutButtonViewHelper.php
Go to the documentation of this file.
1 <?php
2 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 
23 use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
24 
39 {
45  public function ‪initializeArguments(): void
46  {
47  parent::initializeArguments();
48  $this->registerArgument('displayName', 'string', 'Name for the shortcut');
49  $this->registerArgument('getVars', 'array', 'List of additional GET variables to store. The current id, module and all module arguments will always be stored', false, []);
50  }
51 
52  protected static function ‪createButton(‪ButtonBar $buttonBar, array $arguments, RenderingContextInterface $renderingContext): ‪ButtonInterface
53  {
54  $currentRequest = $renderingContext->getControllerContext()->getRequest();
55  $extensionName = $currentRequest->getControllerExtensionName();
56  $moduleName = $currentRequest->getPluginName();
57  $argumentPrefix = GeneralUtility::makeInstance(ObjectManager::class)
58  ->get(ExtensionService::class)
59  ->getPluginNamespace($extensionName, $moduleName);
60 
61  $getVars = $arguments['getVars'];
62  $getVars[] = $argumentPrefix;
63 
64  $shortcutButton = $buttonBar->‪makeShortcutButton()
65  ->‪setDisplayName($arguments['displayName'])
66  ->‪setGetVariables($getVars)
67  ->‪setModuleName($moduleName);
68 
69  return $shortcutButton;
70  }
71 }
‪TYPO3\CMS\Backend\Template\Components\ButtonBar
Definition: ButtonBar.php:31
‪TYPO3\CMS\Backend\ViewHelpers\ModuleLayout\Button\AbstractButtonViewHelper
Definition: AbstractButtonViewHelper.php:31
‪TYPO3\CMS\Backend\Template\Components\Buttons\Action\ShortcutButton\setGetVariables
‪ShortcutButton setGetVariables(array $getVariables)
Definition: ShortcutButton.php:142
‪TYPO3\CMS\Backend\Template\Components\Buttons\Action\ShortcutButton\setModuleName
‪ShortcutButton setModuleName($moduleName)
Definition: ShortcutButton.php:76
‪TYPO3\CMS\Backend\ViewHelpers\ModuleLayout\Button\ShortcutButtonViewHelper\initializeArguments
‪initializeArguments()
Definition: ShortcutButtonViewHelper.php:45
‪TYPO3\CMS\Backend\ViewHelpers\ModuleLayout\Button\ShortcutButtonViewHelper
Definition: ShortcutButtonViewHelper.php:39
‪TYPO3\CMS\Backend\Template\Components\Buttons\Action\ShortcutButton\setDisplayName
‪ShortcutButton setDisplayName($displayName)
Definition: ShortcutButton.php:98
‪TYPO3\CMS\Backend\ViewHelpers\ModuleLayout\Button
Definition: AbstractButtonViewHelper.php:3
‪TYPO3\CMS\Extbase\Service\ExtensionService
Definition: ExtensionService.php:29
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:45
‪TYPO3\CMS\Backend\ViewHelpers\ModuleLayout\Button\ShortcutButtonViewHelper\createButton
‪static createButton(ButtonBar $buttonBar, array $arguments, RenderingContextInterface $renderingContext)
Definition: ShortcutButtonViewHelper.php:52
‪TYPO3\CMS\Extbase\Object\ObjectManager
Definition: ObjectManager.php:25
‪TYPO3\CMS\Backend\Template\Components\ButtonBar\makeShortcutButton
‪ShortcutButton makeShortcutButton()
Definition: ButtonBar.php:140
‪TYPO3\CMS\Backend\Template\Components\Buttons\ButtonInterface
Definition: ButtonInterface.php:21