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