‪TYPO3CMS  ‪main
ShortcutToolbarItem.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 
20 use Psr\Http\Message\ServerRequestInterface;
26 
33 {
34  private ServerRequestInterface ‪$request;
35 
36  public function ‪__construct(
37  private readonly ‪ShortcutRepository $shortcutRepository,
38  private readonly ‪BackendViewFactory $backendViewFactory,
39  ) {}
40 
41  public function ‪setRequest(ServerRequestInterface ‪$request): void
42  {
43  $this->request = ‪$request;
44  }
45 
49  public function ‪checkAccess(): bool
50  {
51  return (bool)($this->‪getBackendUser()->getTSConfig()['options.']['enableBookmarks'] ?? false);
52  }
53 
57  public function ‪getItem(): string
58  {
59  $view = $this->backendViewFactory->create($this->request);
60  return $view->render('ToolbarItems/ShortcutToolbarItemItem');
61  }
62 
66  public function ‪hasDropDown(): bool
67  {
68  return true;
69  }
70 
74  public function ‪getDropDown(): string
75  {
76  $shortcutMenu = [];
77  $groups = $this->shortcutRepository->getGroupsFromShortcuts();
78  arsort($groups, SORT_NUMERIC);
79  foreach ($groups as $groupId => $groupLabel) {
80  $shortcutMenu[] = [
81  'id' => (int)$groupId,
82  'title' => $groupLabel,
83  'shortcuts' => $this->shortcutRepository->getShortcutsByGroup($groupId),
84  ];
85  }
86  $view = $this->backendViewFactory->create($this->request);
87  $view->assign('shortcutMenu', $shortcutMenu);
88  return $view->render('ToolbarItems/ShortcutToolbarItemDropDown');
89  }
90 
94  public function ‪getAdditionalAttributes(): array
95  {
96  return [];
97  }
98 
102  public function ‪getIndex(): int
103  {
104  return 20;
105  }
106 
108  {
109  return ‪$GLOBALS['BE_USER'];
110  }
111 }
‪TYPO3\CMS\Backend\Backend\ToolbarItems\ShortcutToolbarItem\__construct
‪__construct(private readonly ShortcutRepository $shortcutRepository, private readonly BackendViewFactory $backendViewFactory,)
Definition: ShortcutToolbarItem.php:36
‪TYPO3\CMS\Backend\Backend\Shortcut\ShortcutRepository
Definition: ShortcutRepository.php:42
‪TYPO3\CMS\Backend\Toolbar\ToolbarItemInterface
Definition: ToolbarItemInterface.php:22
‪TYPO3\CMS\Backend\Backend\ToolbarItems\ShortcutToolbarItem\getIndex
‪getIndex()
Definition: ShortcutToolbarItem.php:102
‪TYPO3\CMS\Backend\View\BackendViewFactory
Definition: BackendViewFactory.php:35
‪TYPO3\CMS\Backend\Backend\ToolbarItems\ShortcutToolbarItem\getItem
‪getItem()
Definition: ShortcutToolbarItem.php:57
‪TYPO3\CMS\Backend\Backend\ToolbarItems\ShortcutToolbarItem\getBackendUser
‪getBackendUser()
Definition: ShortcutToolbarItem.php:107
‪TYPO3\CMS\Backend\Backend\ToolbarItems\ShortcutToolbarItem\checkAccess
‪checkAccess()
Definition: ShortcutToolbarItem.php:49
‪TYPO3\CMS\Backend\Backend\ToolbarItems\ShortcutToolbarItem\hasDropDown
‪hasDropDown()
Definition: ShortcutToolbarItem.php:66
‪TYPO3\CMS\Backend\Backend\ToolbarItems\ShortcutToolbarItem\getAdditionalAttributes
‪getAdditionalAttributes()
Definition: ShortcutToolbarItem.php:94
‪TYPO3\CMS\Backend\Backend\ToolbarItems
Definition: ClearCacheToolbarItem.php:18
‪TYPO3\CMS\Backend\Backend\ToolbarItems\ShortcutToolbarItem
Definition: ShortcutToolbarItem.php:33
‪TYPO3\CMS\Core\Authentication\BackendUserAuthentication
Definition: BackendUserAuthentication.php:61
‪TYPO3\CMS\Backend\Backend\ToolbarItems\ShortcutToolbarItem\$request
‪ServerRequestInterface $request
Definition: ShortcutToolbarItem.php:34
‪TYPO3\CMS\Backend\Toolbar\RequestAwareToolbarItemInterface
Definition: RequestAwareToolbarItemInterface.php:27
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:25
‪TYPO3\CMS\Backend\Backend\ToolbarItems\ShortcutToolbarItem\getDropDown
‪getDropDown()
Definition: ShortcutToolbarItem.php:74
‪TYPO3\CMS\Backend\Backend\ToolbarItems\ShortcutToolbarItem\setRequest
‪setRequest(ServerRequestInterface $request)
Definition: ShortcutToolbarItem.php:41