TYPO3 CMS  TYPO3_8-7
HelpToolbarItem.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 
26 {
30  protected $helpModuleMenu = null;
31 
35  public function __construct()
36  {
37  $backendModuleRepository = GeneralUtility::makeInstance(BackendModuleRepository::class);
38  $helpModuleMenu = $backendModuleRepository->findByModuleName('help');
39  if ($helpModuleMenu && $helpModuleMenu->getChildren()->count() > 0) {
40  $this->helpModuleMenu = $helpModuleMenu;
41  }
42  }
43 
49  public function checkAccess()
50  {
51  return (bool)$this->helpModuleMenu;
52  }
53 
59  public function getItem()
60  {
61  return $this->getFluidTemplateObject('HelpToolbarItem.html')->render();
62  }
63 
69  public function getDropDown()
70  {
71  $view = $this->getFluidTemplateObject('HelpToolbarItemDropDown.html');
72  $view->assign('modules', $this->helpModuleMenu->getChildren());
73  return $view->render();
74  }
75 
81  public function getAdditionalAttributes()
82  {
83  return [];
84  }
85 
91  public function hasDropDown()
92  {
93  return true;
94  }
95 
101  public function getIndex()
102  {
103  return 70;
104  }
105 
112  protected function getFluidTemplateObject(string $filename): StandaloneView
113  {
114  $view = GeneralUtility::makeInstance(StandaloneView::class);
115  $view->setLayoutRootPaths(['EXT:backend/Resources/Private/Layouts']);
116  $view->setPartialRootPaths(['EXT:backend/Resources/Private/Partials/ToolbarItems']);
117  $view->setTemplateRootPaths(['EXT:backend/Resources/Private/Templates/ToolbarItems']);
118  $view->setTemplate($filename);
119 
120  $view->getRequest()->setControllerExtensionName('Backend');
121  return $view;
122  }
123 }
static makeInstance($className,... $constructorArguments)