TYPO3 CMS  TYPO3_8-7
UserToolbarItem.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 
22 
27 {
33  public function checkAccess()
34  {
35  return true;
36  }
37 
43  public function getItem()
44  {
45  $backendUser = $this->getBackendUser();
46  $view = $this->getFluidTemplateObject('UserToolbarItem.html');
47  $view->assignMultiple([
48  'currentUser' => $backendUser->user,
49  'switchUserMode' => $backendUser->user['ses_backuserid'],
50  ]);
51  return $view->render();
52  }
53 
59  public function getDropDown()
60  {
62  $backendModuleRepository = GeneralUtility::makeInstance(BackendModuleRepository::class);
63  $view = $this->getFluidTemplateObject('UserToolbarItemDropDown.html');
64  $view->assignMultiple([
65  'modules' => $backendModuleRepository->findByModuleName('user')->getChildren(),
66  'logoutUrl' => BackendUtility::getModuleUrl('logout'),
67  'switchUserMode' => $this->getBackendUser()->user['ses_backuserid'],
68  ]);
69  return $view->render();
70  }
71 
77  public function getAdditionalAttributes()
78  {
79  $result = [
80  'class' => 'toolbar-item-user'
81  ];
82  if ($this->getBackendUser()->user['ses_backuserid']) {
83  $result['class'] .= ' su-user';
84  }
85  return $result;
86  }
87 
93  public function hasDropDown()
94  {
95  return true;
96  }
97 
103  public function getIndex()
104  {
105  return 80;
106  }
107 
113  protected function getBackendUser()
114  {
115  return $GLOBALS['BE_USER'];
116  }
117 
125  protected function getFluidTemplateObject(string $filename): StandaloneView
126  {
127  $view = GeneralUtility::makeInstance(StandaloneView::class);
128  $view->setLayoutRootPaths(['EXT:backend/Resources/Private/Layouts']);
129  $view->setPartialRootPaths(['EXT:backend/Resources/Private/Partials/ToolbarItems']);
130  $view->setTemplateRootPaths(['EXT:backend/Resources/Private/Templates/ToolbarItems']);
131 
132  $view->setTemplate($filename);
133 
134  $view->getRequest()->setControllerExtensionName('Backend');
135  return $view;
136  }
137 }
static makeInstance($className,... $constructorArguments)
if(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']