‪TYPO3CMS  10.4
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 
21 
27 {
33  protected ‪$view;
34 
40  protected ‪$defaultViewObjectName = BackendTemplateView::class;
41 
48  protected function ‪resolveView()
49  {
50  ‪$view = parent::resolveView();
52  'extensionName' => $this->request->getControllerExtensionName(),
53  'controllerName' => $this->request->getControllerName(),
54  'actionName' => $this->request->getControllerActionName()
55  ]);
56  return ‪$view;
57  }
58 
62  protected function ‪generateMenu()
63  {
64  $menuItems = [
65  'installedExtensions' => [
66  'controller' => 'List',
67  'action' => 'index',
68  'label' => $this->‪translate('installedExtensions')
69  ],
70  'extensionComposerStatus' => [
71  'controller' => 'ExtensionComposerStatus',
72  'action' => 'list',
73  'label' => $this->‪translate('extensionComposerStatus')
74  ]
75  ];
76 
77  if (!$this->settings['offlineMode'] && !‪Environment::isComposerMode()) {
78  $menuItems['getExtensions'] = [
79  'controller' => 'List',
80  'action' => 'ter',
81  'label' => $this->‪translate('getExtensions')
82  ];
83  $menuItems['distributions'] = [
84  'controller' => 'List',
85  'action' => 'distributions',
86  'label' => $this->‪translate('distributions')
87  ];
88 
89  if ($this->actionMethodName === 'showAllVersionsAction') {
90  $menuItems['showAllVersions'] = [
91  'controller' => 'List',
92  'action' => 'showAllVersions',
93  'label' => $this->‪translate('showAllVersions') . ' ' . $this->request->getArgument('extensionKey')
94  ];
95  }
96  }
97 
98  ‪$uriBuilder = $this->objectManager->get(UriBuilder::class);
99  ‪$uriBuilder->‪setRequest($this->request);
100 
101  $menu = $this->view->getModuleTemplate()->getDocHeaderComponent()->getMenuRegistry()->makeMenu();
102  $menu->setIdentifier('ExtensionManagerModuleMenu');
103 
104  foreach ($menuItems as $menuItemConfig) {
105  if ($this->request->getControllerName() === $menuItemConfig['controller']) {
106  $isActive = $this->request->getControllerActionName() === $menuItemConfig['action'] ? true : false;
107  } else {
108  $isActive = false;
109  }
110  $menuItem = $menu->makeMenuItem()
111  ->setTitle($menuItemConfig['label'])
112  ->setHref($this->‪getHref($menuItemConfig['controller'], $menuItemConfig['action']))
113  ->setActive($isActive);
114  $menu->addMenuItem($menuItem);
115  }
116 
117  $this->view->getModuleTemplate()->getDocHeaderComponent()->getMenuRegistry()->addMenu($menu);
118  $this->view->getModuleTemplate()->setFlashMessageQueue($this->controllerContext->getFlashMessageQueue());
119  }
120 
129  protected function ‪getHref($controller, $action, $parameters = [])
130  {
131  ‪$uriBuilder = $this->objectManager->get(UriBuilder::class);
132  ‪$uriBuilder->‪setRequest($this->request);
133  return ‪$uriBuilder->‪reset()->uriFor($action, $parameters, $controller);
134  }
135 }
‪TYPO3\CMS\Extensionmanager\Controller\AbstractController\translate
‪string translate($key, $arguments=null)
Definition: AbstractController.php:44
‪TYPO3\CMS\Extensionmanager\Controller\AbstractModuleController
Definition: AbstractModuleController.php:27
‪TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder
Definition: UriBuilder.php:39
‪TYPO3\CMS\Extensionmanager\Controller\AbstractModuleController\generateMenu
‪generateMenu()
Definition: AbstractModuleController.php:60
‪TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder\reset
‪static reset()
Definition: UriBuilder.php:534
‪TYPO3\CMS\Extensionmanager\Controller\AbstractModuleController\$defaultViewObjectName
‪string $defaultViewObjectName
Definition: AbstractModuleController.php:38
‪TYPO3\CMS\Extensionmanager\Controller
Definition: AbstractController.php:16
‪TYPO3\CMS\Extensionmanager\Controller\AbstractModuleController\getHref
‪string getHref($controller, $action, $parameters=[])
Definition: AbstractModuleController.php:127
‪TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder\setRequest
‪static setRequest(Request $request)
Definition: UriBuilder.php:168
‪TYPO3\CMS\Extbase\Mvc\Controller\ActionController\$uriBuilder
‪TYPO3 CMS Extbase Mvc Web Routing UriBuilder $uriBuilder
Definition: ActionController.php:127
‪TYPO3\CMS\Extensionmanager\Controller\AbstractModuleController\resolveView
‪TYPO3 CMS Fluid View TemplateView resolveView()
Definition: AbstractModuleController.php:46
‪TYPO3\CMS\Backend\View\BackendTemplateView\assignMultiple
‪TYPO3 CMS Fluid View AbstractTemplateView assignMultiple(array $values)
Definition: BackendTemplateView.php:107
‪TYPO3\CMS\Extensionmanager\Controller\AbstractController
Definition: AbstractController.php:26
‪TYPO3\CMS\Backend\View\BackendTemplateView
Definition: BackendTemplateView.php:28
‪TYPO3\CMS\Core\Core\Environment\isComposerMode
‪static bool isComposerMode()
Definition: Environment.php:144
‪TYPO3\CMS\Core\Core\Environment
Definition: Environment.php:40
‪TYPO3\CMS\Extensionmanager\Controller\AbstractModuleController\$view
‪BackendTemplateView $view
Definition: AbstractModuleController.php:32