‪TYPO3CMS  9.5
AbstractModuleController.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  */
19 
25 {
31  protected ‪$view;
32 
38  protected ‪$defaultViewObjectName = BackendTemplateView::class;
39 
46  protected function ‪resolveView()
47  {
48  ‪$view = parent::resolveView();
50  'extensionName' => $this->request->getControllerExtensionName(),
51  'controllerName' => $this->request->getControllerName(),
52  'actionName' => $this->request->getControllerActionName()
53  ]);
54  return ‪$view;
55  }
56 
60  protected function ‪generateMenu()
61  {
62  $menuItems = [
63  'installedExtensions' => [
64  'controller' => 'List',
65  'action' => 'index',
66  'label' => $this->‪translate('installedExtensions')
67  ]
68  ];
69 
70  if (!$this->settings['offlineMode'] && !‪Environment::isComposerMode()) {
71  $menuItems['getExtensions'] = [
72  'controller' => 'List',
73  'action' => 'ter',
74  'label' => $this->‪translate('getExtensions')
75  ];
76  $menuItems['distributions'] = [
77  'controller' => 'List',
78  'action' => 'distributions',
79  'label' => $this->‪translate('distributions')
80  ];
81 
82  if ($this->actionMethodName === 'showAllVersionsAction') {
83  $menuItems['showAllVersions'] = [
84  'controller' => 'List',
85  'action' => 'showAllVersions',
86  'label' => $this->‪translate('showAllVersions') . ' ' . $this->request->getArgument('extensionKey')
87  ];
88  }
89  }
90 
91  ‪$uriBuilder = $this->objectManager->get(UriBuilder::class);
92  ‪$uriBuilder->setRequest($this->request);
93 
94  $menu = $this->view->getModuleTemplate()->getDocHeaderComponent()->getMenuRegistry()->makeMenu();
95  $menu->setIdentifier('ExtensionManagerModuleMenu');
96 
97  foreach ($menuItems as $menuItemConfig) {
98  if ($this->request->getControllerName() === $menuItemConfig['controller']) {
99  $isActive = $this->request->getControllerActionName() === $menuItemConfig['action'] ? true : false;
100  } else {
101  $isActive = false;
102  }
103  $menuItem = $menu->makeMenuItem()
104  ->setTitle($menuItemConfig['label'])
105  ->setHref($this->‪getHref($menuItemConfig['controller'], $menuItemConfig['action']))
106  ->setActive($isActive);
107  $menu->addMenuItem($menuItem);
108  }
109 
110  $this->view->getModuleTemplate()->getDocHeaderComponent()->getMenuRegistry()->addMenu($menu);
111  $this->view->getModuleTemplate()->setFlashMessageQueue($this->controllerContext->getFlashMessageQueue());
112  }
113 
122  protected function ‪getHref($controller, $action, $parameters = [])
123  {
124  ‪$uriBuilder = $this->objectManager->get(UriBuilder::class);
125  ‪$uriBuilder->setRequest($this->request);
126  return ‪$uriBuilder->reset()->uriFor($action, $parameters, $controller);
127  }
128 }
‪TYPO3\CMS\Extensionmanager\Controller\AbstractController\translate
‪string null translate($key, $arguments=null)
Definition: AbstractController.php:41
‪TYPO3\CMS\Extensionmanager\Controller\AbstractModuleController
Definition: AbstractModuleController.php:25
‪TYPO3\CMS\Extbase\Mvc\Controller\AbstractController\$uriBuilder
‪TYPO3 CMS Extbase Mvc Web Routing UriBuilder $uriBuilder
Definition: AbstractController.php:37
‪TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder
Definition: UriBuilder.php:29
‪TYPO3\CMS\Extensionmanager\Controller\AbstractModuleController\generateMenu
‪generateMenu()
Definition: AbstractModuleController.php:58
‪TYPO3\CMS\Extensionmanager\Controller\AbstractModuleController\$defaultViewObjectName
‪string $defaultViewObjectName
Definition: AbstractModuleController.php:36
‪TYPO3\CMS\Extensionmanager\Controller
Definition: AbstractController.php:2
‪TYPO3\CMS\Extensionmanager\Controller\AbstractModuleController\getHref
‪string getHref($controller, $action, $parameters=[])
Definition: AbstractModuleController.php:120
‪TYPO3\CMS\Extensionmanager\Controller\AbstractModuleController\resolveView
‪TYPO3 CMS Fluid View TemplateView resolveView()
Definition: AbstractModuleController.php:44
‪TYPO3\CMS\Backend\View\BackendTemplateView\assignMultiple
‪TYPO3 CMS Fluid View AbstractTemplateView assignMultiple(array $values)
Definition: BackendTemplateView.php:106
‪TYPO3\CMS\Extensionmanager\Controller\AbstractController
Definition: AbstractController.php:22
‪TYPO3\CMS\Backend\View\BackendTemplateView
Definition: BackendTemplateView.php:27
‪TYPO3\CMS\Core\Core\Environment\isComposerMode
‪static bool isComposerMode()
Definition: Environment.php:117
‪TYPO3\CMS\Core\Core\Environment
Definition: Environment.php:39
‪TYPO3\CMS\Extensionmanager\Controller\AbstractModuleController\$view
‪BackendTemplateView $view
Definition: AbstractModuleController.php:30