‪TYPO3CMS  11.5
AboutController.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
17 
18 use Psr\Http\Message\ResponseInterface;
19 use Psr\Http\Message\ServerRequestInterface;
26 use TYPO3\CMS\Core\Package\PackageManager;
29 use TYPO3Fluid\Fluid\View\ViewInterface;
30 
38 {
44  protected ‪$moduleTemplate;
45 
49  protected ‪$view;
50 
54  protected PackageManager ‪$packageManager;
56 
57  public function ‪__construct(
61  PackageManager ‪$packageManager,
63  ) {
64  $this->version = ‪$version;
65  $this->typo3Information = ‪$typo3Information;
66  $this->moduleLoader = ‪$moduleLoader;
67  $this->moduleLoader->observeWorkspaces = true;
68  $this->moduleLoader->load(‪$GLOBALS['TBE_MODULES']);
69  $this->packageManager = ‪$packageManager;
70  $this->moduleTemplateFactory = ‪$moduleTemplateFactory;
71  }
72 
79  public function ‪indexAction(ServerRequestInterface $request): ResponseInterface
80  {
81  $this->moduleTemplate = $this->moduleTemplateFactory->create($request);
82  $this->‪initializeView('index');
83  $warnings = [];
84  // Hook for additional warnings
85  foreach (‪$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_befunc.php']['displayWarningMessages'] ?? [] as $className) {
86  $hookObj = GeneralUtility::makeInstance($className);
87  if (method_exists($hookObj, 'displayWarningMessages_postProcess')) {
88  $hookObj->displayWarningMessages_postProcess($warnings);
89  }
90  }
91 
92  $this->view->assignMultiple([
93  'copyrightYear' => $this->typo3Information->getCopyrightYear(),
94  'donationUrl' => $this->typo3Information::URL_DONATE,
95  'currentVersion' => $this->version->getVersion(),
96  'loadedExtensions' => $this->getLoadedExtensions(),
97  'copyRightNotice' => $this->typo3Information->getCopyrightNotice(),
98  'warnings' => $warnings,
99  'modules' => $this->getModulesData(),
100  ]);
101 
102  $this->moduleTemplate->setContent($this->view->render());
103  return new HtmlResponse($this->moduleTemplate->renderContent());
104  }
105 
112  protected function ‪getModulesData(): array
113  {
114  $mainModulesData = [];
115  foreach ($this->moduleLoader->getModules() as $moduleName => $moduleInfo) {
116  $moduleLabels = $this->moduleLoader->getLabelsForModule($moduleName);
117  $mainModuleData = [
118  'name' => $moduleName,
119  'label' => $moduleLabels['title'],
120  ];
121  if (is_array($moduleInfo['sub'] ?? null) && !empty($moduleInfo['sub'])) {
122  $mainModuleData['subModules'] = $this->‪getSubModuleData((string)$moduleName);
123  }
124  $mainModulesData[] = $mainModuleData;
125  }
126  return $mainModulesData;
127  }
128 
135  protected function ‪getSubModuleData(string $moduleName): array
136  {
137  if (empty($this->moduleLoader->getModules()[$moduleName]['sub'])) {
138  return [];
139  }
140 
141  $subModulesData = [];
142  foreach ($this->moduleLoader->getModules()[$moduleName]['sub'] ?? [] as $subModuleName => $subModuleInfo) {
143  $moduleLabels = $this->moduleLoader->getLabelsForModule($moduleName . '_' . $subModuleName);
144  $subModuleData = [];
145  $subModuleData['name'] = $subModuleName;
146  $subModuleData['icon'] = $subModuleInfo['icon'] ?? null;
147  $subModuleData['iconIdentifier'] = $subModuleInfo['iconIdentifier'] ?? null;
148  $subModuleData['label'] = $moduleLabels['title'] ?? null;
149  $subModuleData['shortDescription'] = $moduleLabels['shortdescription'] ?? null;
150  $subModuleData['longDescription'] = $moduleLabels['description'] ?? null;
151  $subModulesData[] = $subModuleData;
152  }
153  return $subModulesData;
154  }
155 
161  protected function ‪getLoadedExtensions(): array
162  {
163  $extensions = [];
164  foreach ($this->packageManager->getActivePackages() as $package) {
165  // Skip system extensions
166  if ($package->getPackageMetaData()->isFrameworkType()) {
167  continue;
168  }
169  $extensions[] = [
170  'key' => $package->getPackageKey(),
171  'title' => $package->getPackageMetaData()->getDescription(),
172  'authors' => $package->getValueFromComposerManifest('authors'),
173  ];
174  }
175  return $extensions;
176  }
177 
183  protected function ‪initializeView(string $templateName)
184  {
185  $this->view = GeneralUtility::makeInstance(StandaloneView::class);
186  $this->view->setTemplate($templateName);
187  $this->view->setTemplateRootPaths(['EXT:backend/Resources/Private/Templates/About']);
188  $this->view->setPartialRootPaths(['EXT:backend/Resources/Private/Partials/About']);
189  $this->view->setLayoutRootPaths(['EXT:backend/Resources/Private/Layouts']);
190  }
191 }
‪TYPO3\CMS\Backend\Controller\AboutController\getSubModuleData
‪array getSubModuleData(string $moduleName)
Definition: AboutController.php:133
‪TYPO3\CMS\Backend\Controller\AboutController\indexAction
‪ResponseInterface indexAction(ServerRequestInterface $request)
Definition: AboutController.php:77
‪TYPO3\CMS\Core\Information\Typo3Information
Definition: Typo3Information.php:28
‪TYPO3\CMS\Core\Information\Typo3Version
Definition: Typo3Version.php:21
‪TYPO3\CMS\Backend\Template\ModuleTemplateFactory
Definition: ModuleTemplateFactory.php:29
‪TYPO3\CMS\Backend\Controller\AboutController\initializeView
‪initializeView(string $templateName)
Definition: AboutController.php:181
‪TYPO3\CMS\Backend\Controller\AboutController\$moduleTemplateFactory
‪ModuleTemplateFactory $moduleTemplateFactory
Definition: AboutController.php:53
‪TYPO3\CMS\Backend\Controller\AboutController\getLoadedExtensions
‪array getLoadedExtensions()
Definition: AboutController.php:159
‪TYPO3\CMS\Backend\Controller\AboutController\$packageManager
‪PackageManager $packageManager
Definition: AboutController.php:52
‪TYPO3\CMS\Backend\Controller\AboutController\$typo3Information
‪Typo3Information $typo3Information
Definition: AboutController.php:50
‪TYPO3\CMS\Backend\Template\ModuleTemplate
Definition: ModuleTemplate.php:46
‪TYPO3\CMS\Backend\Controller\AboutController\$version
‪Typo3Version $version
Definition: AboutController.php:49
‪TYPO3\CMS\Backend\Controller\AboutController\__construct
‪__construct(Typo3Version $version, Typo3Information $typo3Information, ModuleLoader $moduleLoader, PackageManager $packageManager, ModuleTemplateFactory $moduleTemplateFactory)
Definition: AboutController.php:55
‪TYPO3\CMS\Backend\Module\ModuleLoader
Definition: ModuleLoader.php:34
‪TYPO3\CMS\Backend\Controller\AboutController\getModulesData
‪array getModulesData()
Definition: AboutController.php:110
‪TYPO3\CMS\Fluid\View\StandaloneView
Definition: StandaloneView.php:31
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:25
‪TYPO3\CMS\Backend\Controller\AboutController\$moduleLoader
‪ModuleLoader $moduleLoader
Definition: AboutController.php:51
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:50
‪TYPO3\CMS\Backend\Controller
Definition: AboutController.php:16
‪TYPO3\CMS\Backend\Controller\AboutController\$moduleTemplate
‪ModuleTemplate $moduleTemplate
Definition: AboutController.php:43
‪TYPO3\CMS\Backend\Controller\AboutController
Definition: AboutController.php:38
‪TYPO3\CMS\Backend\Controller\AboutController\$view
‪ViewInterface $view
Definition: AboutController.php:47
‪TYPO3\CMS\Core\Http\HtmlResponse
Definition: HtmlResponse.php:26