‪TYPO3CMS  ‪main
HelpToolbarItem.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;
27 
32 {
33  protected ?‪MenuModule ‪$helpModule = null;
34  private ServerRequestInterface ‪$request;
35 
36  public function ‪__construct(
37  ‪ModuleProvider $moduleProvider,
38  private readonly ‪BackendViewFactory $backendViewFactory,
39  ) {
40  ‪$helpModule = $moduleProvider->‪getModuleForMenu('help', $this->‪getBackendUser());
41  if ($helpModule && ‪$helpModule->‪hasSubModules()) {
42  $this->helpModule = ‪$helpModule;
43  }
44  }
45 
46  public function ‪setRequest(ServerRequestInterface ‪$request): void
47  {
48  $this->request = ‪$request;
49  }
50 
54  public function ‪checkAccess(): bool
55  {
56  return $this->helpModule !== null;
57  }
58 
62  public function ‪getItem(): string
63  {
64  $view = $this->backendViewFactory->create($this->request);
65  return $view->render('ToolbarItems/HelpToolbarItem');
66  }
67 
71  public function ‪getDropDown(): string
72  {
73  if ($this->helpModule === null) {
74  // checkAccess() is called before and prevents call to getDropDown() if there is no help.
75  throw new \RuntimeException('No HelpModuleMenu found.', 1641993564);
76  }
77  $view = $this->backendViewFactory->create($this->request);
78  $view->assign('modules', $this->helpModule->getSubModules());
79  return $view->render('ToolbarItems/HelpToolbarItemDropDown');
80  }
81 
85  public function ‪getAdditionalAttributes(): array
86  {
87  return [];
88  }
89 
93  public function ‪hasDropDown(): bool
94  {
95  return true;
96  }
97 
101  public function ‪getIndex(): int
102  {
103  return 70;
104  }
105 
107  {
108  return ‪$GLOBALS['BE_USER'];
109  }
110 }
‪TYPO3\CMS\Backend\Backend\ToolbarItems\HelpToolbarItem\getAdditionalAttributes
‪getAdditionalAttributes()
Definition: HelpToolbarItem.php:85
‪TYPO3\CMS\Backend\Toolbar\ToolbarItemInterface
Definition: ToolbarItemInterface.php:22
‪TYPO3\CMS\Backend\Module\MenuModule\hasSubModules
‪hasSubModules()
Definition: MenuModule.php:129
‪TYPO3\CMS\Backend\Backend\ToolbarItems\HelpToolbarItem
Definition: HelpToolbarItem.php:32
‪TYPO3\CMS\Backend\View\BackendViewFactory
Definition: BackendViewFactory.php:35
‪TYPO3\CMS\Backend\Backend\ToolbarItems\HelpToolbarItem\__construct
‪__construct(ModuleProvider $moduleProvider, private readonly BackendViewFactory $backendViewFactory,)
Definition: HelpToolbarItem.php:36
‪TYPO3\CMS\Backend\Backend\ToolbarItems\HelpToolbarItem\setRequest
‪setRequest(ServerRequestInterface $request)
Definition: HelpToolbarItem.php:46
‪TYPO3\CMS\Backend\Backend\ToolbarItems\HelpToolbarItem\getIndex
‪getIndex()
Definition: HelpToolbarItem.php:101
‪TYPO3\CMS\Backend\Backend\ToolbarItems\HelpToolbarItem\getDropDown
‪getDropDown()
Definition: HelpToolbarItem.php:71
‪TYPO3\CMS\Backend\Backend\ToolbarItems\HelpToolbarItem\getItem
‪getItem()
Definition: HelpToolbarItem.php:62
‪TYPO3\CMS\Backend\Module\ModuleProvider
Definition: ModuleProvider.php:29
‪TYPO3\CMS\Backend\Backend\ToolbarItems\HelpToolbarItem\checkAccess
‪checkAccess()
Definition: HelpToolbarItem.php:54
‪TYPO3\CMS\Backend\Backend\ToolbarItems\HelpToolbarItem\hasDropDown
‪hasDropDown()
Definition: HelpToolbarItem.php:93
‪TYPO3\CMS\Backend\Backend\ToolbarItems\HelpToolbarItem\$request
‪ServerRequestInterface $request
Definition: HelpToolbarItem.php:34
‪TYPO3\CMS\Backend\Backend\ToolbarItems\HelpToolbarItem\$helpModule
‪MenuModule $helpModule
Definition: HelpToolbarItem.php:33
‪TYPO3\CMS\Backend\Backend\ToolbarItems
Definition: ClearCacheToolbarItem.php:18
‪TYPO3\CMS\Backend\Module\MenuModule
Definition: MenuModule.php:26
‪TYPO3\CMS\Backend\Module\ModuleProvider\getModuleForMenu
‪getModuleForMenu(string $identifier, BackendUserAuthentication $user, bool $respectWorkspaceRestrictions=true)
Definition: ModuleProvider.php:106
‪TYPO3\CMS\Core\Authentication\BackendUserAuthentication
Definition: BackendUserAuthentication.php:61
‪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\HelpToolbarItem\getBackendUser
‪getBackendUser()
Definition: HelpToolbarItem.php:106