‪TYPO3CMS  11.5
AbstractModuleController.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\ServerRequestInterface;
22 
28 {
30 
32  {
33  $this->moduleTemplateFactory = ‪$moduleTemplateFactory;
34  }
35 
42  protected function ‪resolveView()
43  {
44  ‪$view = parent::resolveView();
46  'extensionName' => $this->request->getControllerExtensionName(),
47  'controllerName' => $this->request->getControllerName(),
48  'actionName' => $this->request->getControllerActionName(),
49  ]);
50  return ‪$view;
51  }
52 
56  protected function ‪initializeModuleTemplate(ServerRequestInterface ‪$request): ‪ModuleTemplate
57  {
58  $menuItems = [
59  'installedExtensions' => [
60  'controller' => 'List',
61  'action' => 'index',
62  'label' => $this->‪translate('installedExtensions'),
63  ],
64  'extensionComposerStatus' => [
65  'controller' => 'ExtensionComposerStatus',
66  'action' => 'list',
67  'label' => $this->‪translate('extensionComposerStatus'),
68  ],
69  ];
70 
71  if (!(bool)($this->settings['offlineMode'] ?? false) && !‪Environment::isComposerMode()) {
72  $menuItems['getExtensions'] = [
73  'controller' => 'List',
74  'action' => 'ter',
75  'label' => $this->‪translate('getExtensions'),
76  ];
77  $menuItems['distributions'] = [
78  'controller' => 'List',
79  'action' => 'distributions',
80  'label' => $this->‪translate('distributions'),
81  ];
82 
83  if ($this->actionMethodName === 'showAllVersionsAction') {
84  $menuItems['showAllVersions'] = [
85  'controller' => 'List',
86  'action' => 'showAllVersions',
87  'label' => $this->‪translate('showAllVersions') . ' ' . $request->getArgument('extensionKey'),
88  ];
89  }
90  }
91 
92  $moduleTemplate = $this->moduleTemplateFactory->create(‪$request);
93  $menu = $moduleTemplate->‪getDocHeaderComponent()->‪getMenuRegistry()->‪makeMenu();
94  $menu->‪setIdentifier('ExtensionManagerModuleMenu');
95 
96  foreach ($menuItems as $menuItemConfig) {
97  if (‪$request->‪getControllerName() === $menuItemConfig['controller']) {
98  $isActive = ‪$request->‪getControllerActionName() === $menuItemConfig['action'] ? true : false;
99  } else {
100  $isActive = false;
101  }
102  $menuItem = $menu->makeMenuItem()
103  ->setTitle($menuItemConfig['label'])
104  ->setHref($this->uriBuilder->reset()->uriFor($menuItemConfig['action'], [], $menuItemConfig['controller']))
105  ->setActive($isActive);
106  $menu->addMenuItem($menuItem);
107  if ($isActive) {
108  $moduleTemplate->setTitle(
109  $this->‪translate('LLL:EXT:extensionmanager/Resources/Private/Language/locallang_mod.xlf:mlang_tabs_tab'),
110  $menuItemConfig['label']
111  );
112  }
113  }
114 
115  $moduleTemplate->getDocHeaderComponent()->getMenuRegistry()->addMenu($menu);
116  $moduleTemplate->setFlashMessageQueue($this->‪getFlashMessageQueue());
117 
118  return $moduleTemplate;
119  }
120 }
‪TYPO3\CMS\Extensionmanager\Controller\AbstractModuleController\resolveView
‪TYPO3 CMS Extbase Mvc View ViewInterface resolveView()
Definition: AbstractModuleController.php:42
‪TYPO3\CMS\Extensionmanager\Controller\AbstractModuleController\injectModuleTemplateFactory
‪injectModuleTemplateFactory(ModuleTemplateFactory $moduleTemplateFactory)
Definition: AbstractModuleController.php:31
‪TYPO3\CMS\Extensionmanager\Controller\AbstractController\translate
‪string translate($key, $arguments=null)
Definition: AbstractController.php:44
‪TYPO3\CMS\Extensionmanager\Controller\AbstractModuleController
Definition: AbstractModuleController.php:28
‪TYPO3\CMS\Backend\Template\ModuleTemplateFactory
Definition: ModuleTemplateFactory.php:29
‪TYPO3\CMS\Extbase\Mvc\Controller\ActionController\$view
‪ViewInterface $view
Definition: ActionController.php:94
‪TYPO3\CMS\Extbase\Mvc\Controller\ActionController\$request
‪Request $request
Definition: ActionController.php:129
‪TYPO3\CMS\Extensionmanager\Controller
Definition: AbstractController.php:16
‪TYPO3\CMS\Backend\Template\Components\Menu\Menu\setIdentifier
‪Menu setIdentifier($identifier)
Definition: Menu.php:73
‪TYPO3\CMS\Backend\Template\ModuleTemplate
Definition: ModuleTemplate.php:46
‪TYPO3\CMS\Extbase\Mvc\Controller\ActionController\getFlashMessageQueue
‪getFlashMessageQueue(?string $identifier=null)
Definition: ActionController.php:852
‪TYPO3\CMS\Backend\Template\Components\MenuRegistry\makeMenu
‪Menu makeMenu()
Definition: MenuRegistry.php:74
‪TYPO3\CMS\Extensionmanager\Controller\AbstractModuleController\$moduleTemplateFactory
‪ModuleTemplateFactory $moduleTemplateFactory
Definition: AbstractModuleController.php:29
‪TYPO3\CMS\Extbase\Mvc\View\ViewInterface\assignMultiple
‪self assignMultiple(array $values)
‪TYPO3\CMS\Extensionmanager\Controller\AbstractController
Definition: AbstractController.php:26
‪TYPO3\CMS\Backend\Template\Components\DocHeaderComponent\getMenuRegistry
‪MenuRegistry getMenuRegistry()
Definition: DocHeaderComponent.php:78
‪TYPO3\CMS\Extbase\Mvc\Request\getControllerName
‪getControllerName()
Definition: Request.php:167
‪TYPO3\CMS\Core\Core\Environment\isComposerMode
‪static bool isComposerMode()
Definition: Environment.php:152
‪TYPO3\CMS\Extensionmanager\Controller\AbstractModuleController\initializeModuleTemplate
‪initializeModuleTemplate(ServerRequestInterface $request)
Definition: AbstractModuleController.php:56
‪TYPO3\CMS\Core\Core\Environment
Definition: Environment.php:43
‪TYPO3\CMS\Backend\Template\ModuleTemplate\getDocHeaderComponent
‪DocHeaderComponent getDocHeaderComponent()
Definition: ModuleTemplate.php:370
‪TYPO3\CMS\Extbase\Mvc\Request\getControllerActionName
‪getControllerActionName()
Definition: Request.php:191